|
-
Apr 14th, 2000, 07:15 AM
#1
Thread Starter
New Member
How do I find out the current millisecond in VB? I know how to get the current hour, minute, and second, but how do I get the current millisecond?
And also, how do I find the timezone offset in VB? For instance, mine is -3.5 (also known as GMT -3:30)
-
Apr 14th, 2000, 09:10 AM
#2
Sure!
Code:
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
Private Declare Sub GetSystemTime Lib "kernel32" (lpSystemTime As SYSTEMTIME)
Private Sub Command1_Click()
Dim udtTime As SYSTEMTIME
Call GetSystemTime(udtTime)
MsgBox udtTime.wHour & ":" & udtTime.wMinute & ":" & udtTime.wSecond & "." & udtTime.wMilliseconds
End Sub
-
Apr 14th, 2000, 10:36 AM
#3
Ohh yeah, I forgot about the Time Zone. Here it is:
Code:
Option Explicit
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
Private Type TIME_ZONE_INFORMATION
Bias As Long
StandardName(32) As Integer
StandardDate As SYSTEMTIME
StandardBias As Long
DaylightName(32) As Integer
DaylightDate As SYSTEMTIME
DaylightBias As Long
End Type
Private Declare Function GetTimeZoneInformation Lib "kernel32" (lpTimeZoneInformation As TIME_ZONE_INFORMATION) As Long
Private Sub Command1_Click()
Dim udtTime As TIME_ZONE_INFORMATION
Dim i As Integer
Dim strBuffer As String
Dim sngOffSet As Single
Dim lngRet As Long
lngRet = GetTimeZoneInformation(udtTime)
If lngRet Then
'Get offset number
sngOffSet = (udtTime.Bias * -1) / 60
'Convert byte array of ASCII characters to readable string
For i = 0 To 32
If udtTime.StandardName(i) = 0 Then Exit For
strBuffer = strBuffer & Chr(udtTime.StandardName(i))
Next
MsgBox "Your Time Zone is: " & strBuffer & " (" & sngOffSet & ")"
Else
MsgBox "Error retrieving TimeZone information."
End If
End Sub
Best regards,
[Edited by Serge on 04-14-2000 at 08:40 PM]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|