文件在磁盘中本来就是二进制保存的,按byte数组读取再转化就行了 Option ExplicitPrivate Sub Command1_Click() Dim FileName As String, PutFileName As String Dim lngFile As Long Dim I As Long, l As Long PutFileName = "c:\1.txt" lngFile = FileLen(PutFileName) '取得文件长度 ReDim myfile(lngFile) As Byte '初始化数组 Open PutFileName For Binary As #1 '打开文件 Get #1, I + 1, myfile '将文件写入数组 Close #1 '关闭 For l = 0 To UBound(myfile) Debug.Print Hex(myfile(l)) Next End Sub
Option ExplicitPrivate Sub Command1_Click()
Dim FileName As String, PutFileName As String
Dim lngFile As Long
Dim I As Long, l As Long
PutFileName = "c:\1.txt"
lngFile = FileLen(PutFileName) '取得文件长度
ReDim myfile(lngFile) As Byte '初始化数组
Open PutFileName For Binary As #1 '打开文件
Get #1, I + 1, myfile '将文件写入数组
Close #1 '关闭
For l = 0 To UBound(myfile)
Debug.Print Hex(myfile(l))
Next
End Sub