我想在保存通过串口收到的数据到.txt文件的同时保存当前时间,这个时间怎么样得到??请指教

解决方案 »

  1.   

    有专门的时间函数的,看下列示例:
    Private Sub Command1_Click()
        Debug.Print Now
        Debug.Print Date
        Debug.Print Time
    End Sub
    输出:
    2005-8-20 14:28:27 
    2005-8-20 
    14:28:27
      

  2.   

    [名称]           获取时间,精确到毫秒[数据来源]       未知[内容简介]       空[源代码内容]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 TypePrivate Function CurrentTime() As String
        Dim SYSTEMTIME As SYSTEMTIME
        
        GetLocalTime SYSTEMTIME
        CurrentTime = SYSTEMTIME.wYear & "-" & _
                      VBA.Format(SYSTEMTIME.wMonth, "00") & "-" & _
                      VBA.Format(SYSTEMTIME.wDay, "00") & " " & _
                      VBA.Format(SYSTEMTIME.wHour, "00") & ":" & _
                      VBA.Format(SYSTEMTIME.wMinute, "00") & ":" & _
                      VBA.Format(SYSTEMTIME.wSecond, "00") & "." & _
                      VBA.Format(SYSTEMTIME.wMilliseconds, "000")
    End Function
         以上代码保存于: SourceCode Explorer(源代码数据库)
               复制时间: 2005-08-20 20:07:47
               软件版本: 1.0.870
               软件作者: Shawls
                 E-Mail: [email protected]
                     QQ: 9181729