Vb6 如何在两个标签中区分时间和日期?我的代码在1个标签中同时显示时间和日期
'将通用时钟偏移量从 注册表中没有说明日光 储蓄Vb6 如何在两个标签中区分时间和日期?我的代码在1个标签中同时显示时间和日期,vb6,utc,Vb6,Utc,'将通用时钟偏移量从 注册表中没有说明日光 储蓄 Private Sub Timer1_Timer() Dim datUTC As Date datUTC = Time_LocalToUTC(Now) Me.lblCurrentTimeActual.Caption = Now Me.lblUTCTimeActual.Caption = CStr(datUTC) Me.lblPhilippinesTimeActual.Caption = CStr(DateAdd("h", 8, datUTC
Private Sub Timer1_Timer()
Dim datUTC As Date
datUTC = Time_LocalToUTC(Now)
Me.lblCurrentTimeActual.Caption = Now
Me.lblUTCTimeActual.Caption = CStr(datUTC)
Me.lblPhilippinesTimeActual.Caption =
CStr(DateAdd("h", 8, datUTC))
End Sub
Public Function Time_LocalToUTC(ByVal
the_date As Date) As Date
On Error GoTo ErrorTrap
' Create a new instance of the WScript
Shell
Dim oWshshell As Variant
Dim UTCOffset As Long
Set oWshshell =
CreateObject("WScript.Shell")
'获取当前系统时间,并从注册表中添加UTC偏移量。1440是生产的
'因为一天的单位等于一天,所以取60*24
时间=日期+(UTCOffset/1440)
GoTo EndCleanup
错误陷阱:
MsgBox“错误:&错误说明,
vbOKCancel,“获取UTC时间时出错”
这就解决了问题。lol
现在
将同时显示日期和时间<代码>日期仅显示日期,时间
仅显示时间。以防您找不到VB6语言参考的链接。
UTCOffset = oWshshell.RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation\ActiveTimeBias")
EndCleanup:
Set oWshshell = Nothing
End Function[enter image description here]
[1]
Me.Label1.Caption = Format$(CStr(DateAdd("h", 8,
datUTC)), "hh:mm:ss AM/PM")
Me.Label2.Caption = Format$(CStr(DateAdd("h", 8,
datUTC)), " mmmm dd, yyyy")