如何把二进制数据(通过VB从文件中读取的)转换成正常的字符串?我急需要解决,请各位大侠帮帮忙,谢谢!
我采用VB以二进制方式读取文件时,出现不能把二进制数据正常转换成字符串(即:转一部分换成了非法字符串,尤其是文件中包含的非英文字符)问题。请各位大侠帮帮忙(最好提供源码),我现在急需要解决这个问题,在此,我再次向你表示感谢。以下是我的一些源码:
Private Sub cmdTest_Click()
Dim b As Byte
Dim fl As Long
Dim sect As Long
Dim ss As Long
Dim index As Long
Dim hNewFile As Long
Dim lSize As Long
Dim intSN As Integer
On Error GoTo Error1
intSN = 0
FileName = Trim(txtCCICFilePath.Text) ' 文件名
Filenum = FreeFile
fl = FileLen(txtCCICFilePath.Text)
sect = fl / 16
ss = fl Mod 16
Open FileName For Binary As #Filenum
If sect = 0 Then
For index = 1 To ss
Get #1, index, b
Next index
End If
lSize = 64
ReDim LoadBytes(1 To lSize ) As Byte
If sect <> 0 Then
For i = 1 To fl Step lSize
Get #Filenum, i, LoadBytes
Text1.Text = Text1.Text + StrConv(LoadBytes, vbUnicode)
Next
End If
Close #Filenum
Exit Sub
Error1:
MsgBox Err.Description
End Sub
'请各位看看我主要错在哪儿,Thanks a lot!