这里是一个子程序可以让你开始:
Public Sub ProcessData()
Dim inputFileName As String
Dim outputFileName As String
Dim wordCount As Integer
Dim i As Integer
Dim msb As Byte
Dim lsb As Byte
Dim unsignedWord As Long
Dim word As Integer
inputFileName = "C:\Input.bin"
outputFileName = "C:\Output.bin"
wordCount = FileLen(inputFileName)/2
Open inputFileName For Binary Access Read As #1
Open outputFileName For Binary Access Write As #2
For i = 1 To wordCount
Get #1, , msb
Get #1, , lsb
unsignedWord = CLng(msb) * 256 + lsb
If unsignedWord > 32768 Then
word = -CInt(65536 - unsignedWord)
Else
word = CInt(unsignedWord)
End If
' Do something with each word.
word = -word
If word < 0 Then
unsignedWord = 65536 + word
Else
unsignedWord = word
End If
msb = CByte(unsignedWord/256)
lsb = CByte(unsignedWord Mod 256)
Put #2, , msb
Put #2, , lsb
Next
Close #1
Close #2
End Sub