28,406
社区成员
发帖
与我相关
我的任务
分享
Public Function BinaryToString(ByVal BinaryStr As Variant) As String
'On Error Resume Next
Dim lnglen As Long
Dim tmpBin As Variant
Dim strC As String
Dim skipflag As Long
Dim i As Long
skipflag = 0
strC = ""
If Not IsNull(BinaryStr) Then
lnglen = LenB(BinaryStr)
For i = 1 To lnglen
If skipflag = 0 Then
tmpBin = MidB(BinaryStr, i, 1)
If AscB(tmpBin) > 127 Then
strC = strC & Chr(AscW(MidB(BinaryStr, i + 1, 1) & tmpBin))
skipflag = 1
Else
strC = strC & Chr(AscB(tmpBin))
End If
Else
skipflag = 0
End If
Next
End If
BinaryToString = strC
End Function
Public Function Getfile(FileName As String)
Dim DAT() As Byte
Dim FileSize As Long '文件长度
FileSize = FileLen(FileName) '获取文件长度
ReDim DAT(FileSize - 1) As Byte
Open FileName For Binary As #1
Get #1, , DAT
Close
Getfile = BinaryToString(DAT)
End Function