我正在尝试创建一个项目,以使我可以从特定文件中读取二进制文件,也可以从文件中的特定偏移量读取文件。
我发现以下代码没有主要来源:
Sub GetData()
Dim nFileNum As Integer, sLocation1 As String, sLocation2 As String 'declarations
nFileNum = FreeFile 'get file ID
Open App.Path & "\Hologram.bin" For Binary Access Read Lock Read Write As #nFileNum 'file to open
sLocation1 = Space$(10) 'my first offset is 10 chars long, set a string placeholder must equal the size of data you want to hold
sLocation2 = Space$(32) 'my second offset is 32 chars longs, set a string placeholder must equal the size of data you want to hold
Get #nFileNum, 12000, sLocation1 'The offset location in Binary of the data I want to show (+1 to offset because we start at 0!)
Text1.Text = sLocation1 'display the 10 chars data in a textbox
Get #nFileNum, 12500, sLoation2 ' The offset location in Binary of the data I want to show (+1 to offset because we start at 0!)
Text2.Text = sLocation2 'display the 32 chars data in a textbox
Close #nFileNum 'Cloase the file
End Sub 'Call GetData()
Sub WriteBin()
Dim sFileText As String 'declarations
Dim iFileNo As Integer
iFileNo = FreeFile
Dim nFileNum As Integer
nFileNum = FreeFile 'get random file number
Open App.Path & "filename.bin" For Binary Access Write Lock Read Write As #nFileNum 'open file for edit
Put #nFileNum, 12000, Text1.Text 'Offset is +1 because we start at 0! write data from textbox1 to offset location
Put #nFileNum, 12500, Text2.Text 'Offset is +1 because we start at 0! write data from textbox2 to offset location
Close #nFileNum 'Call WriteBin()
End Sub
我想找到这段代码的其余部分,以便可以使用它。 谢谢