I have to read a 4 byte Int from a text file add one on and write it back.

I have a text file with 1 record which is 512 bytes long
byte 257,258,259,260 is an int

That 4 byte field is a binary intel format integer, in standard
intel layout (i.e low byte, high byte, low byte, high byte). So for example
- a 93 decimal would be stored as:
0x5D 0x00 0x00 0x00

how can I read this add one and write it back
have triwd the following with no success (there are other ints and hex etc in this file it is not all ascii!!
(this int is onlt between 1 and 999 rolling)

I cannot change the layout of the file as it is in use by another application that I cannot change.


Open "TEST.TXT" For Input As #1
Dim byte1 As Integer
Dim byte2 As Integer
Dim byte3 As Integer
Dim byte4 As Integer
Dim t_wsr As Integer

Line Input #1, linedata
byte1 = Asc(Mid(linedata, 257, 1))
byte3 = Asc(Mid(linedata, 259, 1)) * 256
t_wsr = byte1 + byte2
t_wsr = t_wsr + 1
If t_wsr = 1000 Then
t_wsr = 1
End If
byte1 = t_wsr Mod 256
byte3 = Int((t_wsr Mod 65536) / 256)
byte2 = &H0
byte4 = &H0

Close #1
Open remote_drive & file_name For Output As #1
Print #1, Left(linedata, 257) & Chr$(byte1) & Chr$(byte2) & Chr$(byte3) & Chr$(byte4) & Space(251)
Close #1


Help Please