Hi all,
my name is Luigi and i'm working on little windows app to send trought serial port some hex value from file.
With following routine i get the total contens of thext file in a list box.

        Sub ToolStripMenuItem1Click(sender As Object, e As EventArgs)
            openFileDialog1.ShowDialog
            textBox1.Visible = True
            listBox1.Visible = True
            listBox2.Visible = True

            textBox1.text = openFileDialog1.FileName
            groupBox3.Text = "Percorso e Nome File"
            groupBox2.Text = "Indirizzo e Codice"
            groupBox1.Text = "Contenuto del file HEX"

            listBox1.Items.Clear
            listBox2.Items.Clear

            Dim a As String = My.Computer.FileSystem.ReadAllText(openFileDialog1.FileName)
            Dim c As String() = a.Split(vbNewLine)
            listBox1.Items.AddRange(c)

        End Sub

The file is an hex file. The structure of each string of the file is:
1. first caracter is ":";
2. 2nd and 3rd char is the nr. of byte stored in string;
3. 4,5,6,7 char is the memory address;
4. from 1 to 16 char are the byte;
5. last 2 char are not necessary.

ex. :1001000006003E00CD24023E40321B803E003212EB

: 10 (there are 16 couple of char) 0100 (memory address) 00 06 00 3E 00 CD 24 02 3E 40 32 1B 80 3E 00 32 12 (byte)

From each line of the file, i need to extract the memory address and the bytes; convert them in numeric format and send trought serial port.

Can someone help me please?
Thank You.
Luigi.

Try using a byte array and the ReadAllBytes method instead. From there a simple For loop stepped the length of each section should be able to parse it.

Edited 3 Years Ago by tinstaafl

Hi tinstaafl, thank you for your reply.
Can you post sample code please?
Thank You.

This article has been dead for over six months. Start a new discussion instead.