Visual basic

Como puedo colocar la hora del sistema en visual basic..
te lo agradeceria

1 respuesta

Respuesta
1
Si quieres "TOMAR" la hora del sistema en Visual Basic, prueba esta rutina que tome del API-GUIDE www.allapi.net te lo recomiendo.
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
Private Sub Form_Load()
'KPD-Team 1998
'URL: http://www.allapi.net/
'E-Mail: [email protected]
Dim MyTime As SYSTEMTIME
'Set the graphical mode to persistent
Me.AutoRedraw = True
'Get the local time
GetLocalTime MyTime
'Print it to the form
Me.Print "The Local Date is:" & MyTime.wMonth & "-" & MyTime.wDay & "-" & MyTime.wYear
Me.Print "The Local Time is:" & MyTime.wHour & ":" & MyTime.wMinute & ":" & MyTime.wSecond
End Sub
Ahora bien, si quieres "SETEAR" la hora del sistema, puedes usar la siguiente rutina que tambien copie del www.allapi.com
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 Function SetSystemTime Lib "kernel32" (lpSystemTime As SYSTEMTIME) As Long
Private Sub Form_Load()
'KPD-Team 2000
'URL: http://www.allapi.net/
'E-Mail: [email protected]
Dim lpSystemTime As SYSTEMTIME
lpSystemTime.wYear = 2000
lpSystemTime.wMonth = 1
lpSystemTime.wDayOfWeek = -1
lpSystemTime.wDay = 24
lpSystemTime.wHour = 23
lpSystemTime.wMinute = 26
lpSystemTime.wSecond = 0
lpSystemTime.wMilliseconds = 0
'set the new time
SetSystemTime lpSystemTime
End Sub

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas