Read bin file

domtorredo

New member
Joined
Jan 25, 2014
Messages
1
Programming Experience
Beginner
Hi
First sorry for bad my English and not naming things in correct names.
Started learning vb few month ago and attempted first project
main things what app must do is to read bytes correct me if named incorrectly
have spent days reading tutorials etc

for start have cid.bin file with few lines but some info from these needs to be displayed
1st 000000: 30 30 30 38 00 31 00 00 00 00 00 00 00 00 89 CE
2nd 0000C0: 98 48 8E 4F 23 05 24 83 FF 00 A0 82 65 72 39 35
3rd 0000D0: 39 38 20 80 07 08 00 01 99 CA 00 91 97 CA 42 4A

info needed 1st in hex that's 30 30 30 38 what needs to be displayed as 0008 and 31 what needs to be displayed as 1
from 2nd and 3rd 39 35 39 38 but displayed as 5989
to organize it all would be nice to display it like
info 1: 0008
info 2: 1
info 3: 5989
but not in textbox but something like on app background
as optional want to include 39 35 39 38 to rewrite to FF FF FF FF with button
and possibility to save displayed data to txt file

for now have made some progress but it looks like a hex editor it opens a file and displays all hex values rich textbox in one chunk without spaces
can add some text too but managed it to accept only hex values that's really not needed for me
for now code looks
Imports System.IO
Public Class Main
Dim hexString As String
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If open_openfiledialog.ShowDialog() = Windows.Forms.DialogResult.OK Then
Using file As New IO.FileStream(open_openfiledialog.FileName, IO.FileMode.Open)
Dim value As Integer = file.ReadByte()
Do Until value = -1
hexString = hexString & (value.ToString("X2"))
value = file.ReadByte()
Loop
End Using
hex_richtextbox.Text = hexString
End If
End Sub
Private Sub hex_richtextbox_KeyPress(sender As Object, e As KeyPressEventArgs) Handles hex_richtextbox.KeyPress
If (Asc(e.KeyChar) >= 48 And Asc(e.KeyChar) <= 57) Or (Asc(e.KeyChar) >= 65 And Asc(e.KeyChar) <= 70) Or (Asc(e.KeyChar) >= 97 And Asc(e.KeyChar) <= 102) Or (Asc(e.KeyChar) = 8 Or Asc(e.KeyChar) = 16) Then
e.Handled = False
Else
e.Handled = True
End If
End Sub
End Class

if someone can help a bit of sorting this out would be really great as I got stuck with this and cant find much info too
Thanks in advance
 
Back
Top