帮忙写一个函数:读取当前系统时间再写入二进制文件中。
如题
用模块写个函数,读取系统的时间,日期,再写入二进制文件中。
小弟没学过有关二进制的问题,还请各位赐教,谢谢了,如果能顺带讲解一下更是感激。
[解决办法]
Private Sub SaveTimeToFile(ByVal mfile As String)
Open mfile For Binary As #1
Put #1, , Now
Close #1
End Sub
[解决办法]
我给加个解释吧
Private Sub SaveTimeToFile(ByVal mfile As String)
Open mfile For Binary As #1 '打开路径为mfile的文件
Put #1, , Now 'now是一个函数取得当前系统时间
'put语句为写2进制文件
Close #1 '关闭打开的文件
End Sub
[解决办法]
Private Declare Sub CopyMemory Lib "kernel32 " Alias "RtlMoveMemory " (Destination As Any, Source As Any, ByVal Length As Long)
Private Sub InputDate(dtmData as Date)
Dim bytA(7) As Byte
Dim bytB(7) As Byte
Dim dtmDateA As Date
Dim dtmDateB As Date
dtmDateA = dtmData
Call CopyMemory(bytA(0), dtmDateA, 8)
Open "mfile.dat " For Binary As #1
Put #1, , bytA
Close #1
' Check
Open "mfile.dat " For Binary As #1
Get #1, , bytB
Close #1
Call CopyMemory(dtmDateB, bytB(0), 8)
End Sub