我想知道如何更改系统时间用VB

解决方案 »

  1.   

    不知道有没有其他好方法。
    Declare Function SetSystemTime Lib "kernel32" Alias "SetSystemTime" (lpSystemTime As SYSTEMTIME) As Long
    ====================
    Type SYSTEMTIME ' 16 Bytes 
    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 
    说明 
    This structure contains date and time information.
     
    字段表 
    字段 类型与说明 
    wYear Integer,The current year. 
    wMonth Integer,The current month. January is 1. 
    wDayOfWeek Integer,The current day of the week. Sunday is 0. 
    wDay Integer,The current day of the month. 
    wHour Integer,The current hour. 
    wMinute Integer,The current minute. 
    wSecond Integer,The current second. 
    wMilliseconds Integer,The current millisecond. 
      

  2.   

    Option Explicit
    Private Declare Function SetSystemTime Lib "kernel32" (lpSystemTime As SYSTEMTIME) As LongPrivate Type SYSTEMTIME ' 16 Bytes
    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 TypeDim a As SYSTEMTIMEPrivate Sub Form_Load()
    Dim d As Long
        a.wYear = 2004
        a.wMonth = 11
        a.wDayOfWeek = 0
        a.wDay = 3
        a.wHour = 15
        a.wMinute = 25
        a.wSecond = 34
        a.wMilliseconds = 1
        d = SetSystemTime(a)
    End Sub
      

  3.   

    Dim MyTime
    MyTime = #4:35:17 PM#   ' 指定一时间。
    Time = MyTime   ' 将系统时间设置为 MyTime 的内容。
      

  4.   

    靠,一楼二楼的,用这么多代码累不累啊。一条语句:Time = CDate("2004-11-03 15:49:32")
      

  5.   

    这个也要写那样长的代码,误人子弟同意楼上的:
            time= CDate("2004-11-03 15:49:32")改为
        date= CDate("2004-11-03 15:49:32")
      

  6.   

    或者是
         now=CDate("2004-11-03 15:49:32")
      

  7.   

    Time = CDate("2004-11-03 15:49:32")
    好经典啊以前还用一大堆麻烦的API
      

  8.   

    Time = "12:12"自己试用一下即了解!
      

  9.   

    hehe ,简单明了,弓虽,丁页!Time=……
      

  10.   

    Date = CDate("2004-12-03")
      Time = CDate("2004-11-03 15:49:32")
    强啊