VB6 用api获取系统时间实现毫秒计时的问题 高分求解
您好,我目前正为学校开发一款运动会信息化管理的软件。但是在设计终点计时的时候出现了问题:我使用的计时代码如下:PrivateDeclareSubGetLocalTimeL...
您好,我目前正为学校开发一款运动会信息化管理的软件。但是在设计终点计时的时候出现了问题:我使用的计时代码如下:
Private Declare Sub GetLocalTime Lib "kernel32" (lpSystemTime As SYSTEMTIME)
Private Type SYSTEMTIME
wYear As Integer
wMonth As Integer
wDayOfWeek As Integer
wDay As Integer
wHour As Integer
wMinute As Integer
wSecond As Integer
wMilliseconds As Integer
End Type
Dim t1 As SYSTEMTIME
Dim t2 As SYSTEMTIME
Dim h As Integer
Dim m As Integer
Dim s As Integer
Dim ms As Integer
Function timesave() As String
'程序的主要部分,自定义过程用于记录时间间隔
GetLocalTime t2
h = t2.wHour - t1.wHour
m = t2.wMinute - t1.wMinute
s = t2.wSecond - t1.wSecond
ms = t2.wMilliseconds - t1.wMilliseconds
If ms < 0 Then ms = ms + 1000: s = s - 1
If s < 0 Then s = s + 60: m = m - 1
If m < 0 Then m = m + 60: h = h - 1
timesave = "时间" & h & "小时" & m & "分钟" & s & "秒" & ms & "毫秒"
End Function
Private Sub Command1_Click()
GetLocalTime t1
Timer1.Enabled = True
End Sub
Private Sub Command2_Click()
Timer1.Enabled = 0
Label1.Caption = timesave()
End Sub
Private Sub Form_Load()
Label1 = "计时"
Command1.Caption = "开始计时:"
Command2.Caption = "停止计时"
Timer1.Interval = 88
End Sub
Private Sub Timer1_Timer()
Label1.Caption = timesave()
End Sub
当它单独在一个只含有一个窗体的工程文件中时运行正常。但一旦把它写进我的这个工程中的终点计时窗体时,就提示“在该对象模块派送的模块中成员已存在”。请问这是怎么一回事?该如何解决呢?真的搞不明白了... 展开
Private Declare Sub GetLocalTime Lib "kernel32" (lpSystemTime As SYSTEMTIME)
Private Type SYSTEMTIME
wYear As Integer
wMonth As Integer
wDayOfWeek As Integer
wDay As Integer
wHour As Integer
wMinute As Integer
wSecond As Integer
wMilliseconds As Integer
End Type
Dim t1 As SYSTEMTIME
Dim t2 As SYSTEMTIME
Dim h As Integer
Dim m As Integer
Dim s As Integer
Dim ms As Integer
Function timesave() As String
'程序的主要部分,自定义过程用于记录时间间隔
GetLocalTime t2
h = t2.wHour - t1.wHour
m = t2.wMinute - t1.wMinute
s = t2.wSecond - t1.wSecond
ms = t2.wMilliseconds - t1.wMilliseconds
If ms < 0 Then ms = ms + 1000: s = s - 1
If s < 0 Then s = s + 60: m = m - 1
If m < 0 Then m = m + 60: h = h - 1
timesave = "时间" & h & "小时" & m & "分钟" & s & "秒" & ms & "毫秒"
End Function
Private Sub Command1_Click()
GetLocalTime t1
Timer1.Enabled = True
End Sub
Private Sub Command2_Click()
Timer1.Enabled = 0
Label1.Caption = timesave()
End Sub
Private Sub Form_Load()
Label1 = "计时"
Command1.Caption = "开始计时:"
Command2.Caption = "停止计时"
Timer1.Interval = 88
End Sub
Private Sub Timer1_Timer()
Label1.Caption = timesave()
End Sub
当它单独在一个只含有一个窗体的工程文件中时运行正常。但一旦把它写进我的这个工程中的终点计时窗体时,就提示“在该对象模块派送的模块中成员已存在”。请问这是怎么一回事?该如何解决呢?真的搞不明白了... 展开
若以下回答无法解决问题,邀请你更新回答
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询