VB中怎样用format函数调动系统时间并动态显示

如题所述

第1个回答  2017-05-18
得到系统时间:
1.使用C
Time类
CTime tm=CTime::GetCurrentTime();
CString str=tm.Format(“现在时间是:%Y年%m月%d日 %X”);
MessageBox(str,NULL,MB_OK);
2: 得到系统时间日期(使用GetLocalTime)
SYSTEMTIME st;
CString strDate,strTime;
GetLocalTime(&st);
strDate.Format(“%4d-%2d-%2d”,st.wYear,st.wMonth,st.wDay);
strTime.Format(“%2d:%2d:%2d”,st.wHour,st.wMinute,st.wSecond);
3.使用GetTickCount//获取程序运行时间
long t1=GetTickCount();//程序段开始前取得系统运行时间(ms)
……//程序段
long t2=GetTickCount();//程序段结束后取得系统运行时间(ms)本回答被网友采纳
相似回答