Private Declare Function timeKillEvent Lib "winmmdll" (ByVal uID As Long) As Long
Private Declare Function timeSetEvent Lib "winmmdll" (ByVal uDelay As Long, ByVal uResolution As Long, ByVal lpFunction As Long, ByVal dwUser As Long, ByVal uFlags As Long) As Long
Dim p As Long
Private Const TIME_周期 As Long = 1
Private Const TIME_一次性 As Long = 0
Private Sub Form_DblClick()
timeKillEvent p
p = 0
End Sub
Private Sub Form_Load()
p = timeSetEvent(300000, 10, AddressOf TimeProc, 1, TIME_一次性)
DebugPrint timeGetTime
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If p Then timeKillEvent p: p = 0: Cancel = True: Timer1Enabled = True
End Sub
Private Sub Timer1_Timer()
Timer1Enabled = False
Unload Me
End Sub
[/font]
模块代码:
Option Explicit
Public Declare Function timeGetTime Lib "winmmdll" () As Long
Sub TimeProc(ByVal uID As Long, ByVal uMsg As Long, ByVal dwUser As Long, ByVal dw1 As Long, ByVal dw2 As Long)
DebugPrint timeGetTime
End Sub
Now函数:返回系统的日期和时间。
Format函数:根据格式表达式来格式化数据。
date()例子:在PHP中
<php
// 设定要用的默认时区。自 PHP 51 可用:
date_default_timezone_set('UTC');
// 输出类似:
Mondayecho date("l");
// 输出类似:
Monday 15th of August 2005 03:12:46 PMecho date('l dS \of F Y h:i:s A');
// 输出:July 1, 2000 is on a Saturdayecho "July 1, 2000 is on a "
date("l", mktime(0, 0, 0, 7, 1, 2000));
/ 在格式参数中使用常量 /
// 输出类似:Mon, 15 Aug 2005 15:12:46
UTCecho date(DATE_RFC822);
// 输出类似:2000-07-01T00:00:00+0000echo
date(DATE_ATOM, mktime(0, 0, 0, 7, 1, 2000));
>
扩展资料:
作用Date 函数可返回当前的系统日期。
提示:获取时间可参考Time()函数
语法
Date
实例
Dim MyDate
MyDate = Date ' MyDate 的值为系统当前的日期(如:2010-07-03)。
说明
VB 中Date语句可以用于设置系统日期
如:
Date = "2012-8-8" '这样就把当前系统日期改为2012-8-8了
Option ExplicitDim Time_Star
Private Sub Command1_Click()
If Command1Caption = "开始计时" Then
Time_Star = Timer
Command1Caption = "停止"
Timer1Enabled = True
ElseIf Command1Caption = "停止" Then
Timer1Enabled = False
Command1Caption = "开始计时"
End If
End Sub
Private Sub Command2_Click()
Text1Text = ""
Text2Text = ""
End Sub
Private Sub Form_Load()
Timer1Interval = 1000
Timer2Interval = 1000
End Sub
Private Sub Timer1_Timer()
Text2Text = Timer - Time_Star
End Sub
Private Sub Timer2_Timer()
Text1Text = Now
End Sub
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)