R
Rory Becker
The following code is being used in a VB6 program to read and write a simple
binary file.
I need to move things into the 21st century and recode this in VB.Net
The new VB.Net program will need to continue to operate in the same enterprise
level situation.
Rollout will be slow and so for the moment the new code will have to be able
to read and write these files in the exact same format as the Old VB6 code.
The code is:
-------------------------------------------------------------
Public Type TransferHeader
Hub As String
Version As Long ' I appreciate that this should be an Integer in VB.Net
End Type
Private Sub SetFileHeaderData(Filename As String, Data As TransferHeader)
Dim DataFile As Byte
DataFile = FreeFile()
Open Filename For Binary Access Write As #DataFile
Put #DataFile, , Data
Close #DataFile
End Sub
Private Function GetHeaderOfFile(HeaderFile As String) As TransferHeader
Dim TempHeader As TransferHeader
Dim DataFile As Byte
DataFile = FreeFile()
Open HeaderFile For Binary Access Read As #DataFile
Do Until EOF(DataFile)
Get #DataFile, , TempHeader
If Len(TempHeader.Hub) > 0 Then
GetHeaderOfFile = TempHeader
End If
Loop
Close #DataFile
End Function
binary file.
I need to move things into the 21st century and recode this in VB.Net
The new VB.Net program will need to continue to operate in the same enterprise
level situation.
Rollout will be slow and so for the moment the new code will have to be able
to read and write these files in the exact same format as the Old VB6 code.
The code is:
-------------------------------------------------------------
Public Type TransferHeader
Hub As String
Version As Long ' I appreciate that this should be an Integer in VB.Net
End Type
Private Sub SetFileHeaderData(Filename As String, Data As TransferHeader)
Dim DataFile As Byte
DataFile = FreeFile()
Open Filename For Binary Access Write As #DataFile
Put #DataFile, , Data
Close #DataFile
End Sub
Private Function GetHeaderOfFile(HeaderFile As String) As TransferHeader
Dim TempHeader As TransferHeader
Dim DataFile As Byte
DataFile = FreeFile()
Open HeaderFile For Binary Access Read As #DataFile
Do Until EOF(DataFile)
Get #DataFile, , TempHeader
If Len(TempHeader.Hub) > 0 Then
GetHeaderOfFile = TempHeader
End If
Loop
Close #DataFile
End Function