我正在尝试更改字节流数组中的值。我正在寻找 Null 值,我想将其更改为空格。当我尝试访问该数组时,我收到一条错误消息“类型不匹配”。
我的 VBS 代码:
Const adTypeBinary = 1
Const adSaveCreateOverWrite = 2
Const adSaveCreateNotExist=1
'Create Stream object
Dim BinaryStream
Set BinaryStream = CreateObject("ADODB.Stream")
Dim InputFile
InputFile="C:\Users\oferbe\Documents\Tfachut\prepr\Testinput.txt"
'Specify stream type - we want To get binary data.
BinaryStream.Type = adTypeBinary
'Open the stream
BinaryStream.Open
'Load the file data from disk To stream object
BinaryStream.LoadFromFile InputFile
'Open the stream And get binary data from the object
ReadBinaryFile = BinaryStream.Read
BinaryStream.Close
For i = 0 to UBound(ReadBinaryFile)
If ReadBinaryFile(i)=00 Then ReadBinaryFile(i)=20
Next
BinaryStream.Open
'BinaryStream.Write ByteArray
BinaryStream.Write ReadBinaryFile
Dim OutPutFile
OutPutFile="C:\Users\oferbe\Documents\Tfachut\prepr\Ofer"
'Save binary data To disk
BinaryStream.SaveToFile OutPutFile, adSaveCreateOverWrite