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)
            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"


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

        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.

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.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.