在vb下用系统当前时间生成一个字符串,要精确到毫秒。
请问要如何解决?

解决方案 »

  1.   

    http://dfs.iis.u-tokyo.ac.jp/~maoxc/vb/137.htm
      

  2.   

    用API函数GetSystemTime 
    Dim sysTime As SYSTEMTIME 
    GetSystemTime sysTime 
    此时systime返回当前得系统时间(毫秒级) 
    类型:SYSTEMTIME定义如下 
    Public 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 
      

  3.   

    Public 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
    Public Declare Sub GetLocalTime Lib "kernel32" (lpSystemTime As SYSTEMTIME)
    dim a as SYSTEMTIME
    GetLocalTime a
    解析结构a即可
      

  4.   

    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()
        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 & ":" & MyTime.wMilliseconds
    End Sub