Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.
When asked, what has been your best career decision?
Deciding to stick with EE.
Being involved with EE helped me to grow personally and professionally.
Connect with Certified Experts to gain insight and support on specific technology challenges including:
We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE
Public Shared magic_number As UShort Public Shared flag_block1 As ULong Public Shared flag_block2 As ULong Public Shared serial_no As String Public Shared bytes(0 To 9) As Byte Public Shared dig_fw_ver As UShort Public Shared lcd_fw_ver As UShort Public Shared sd_fw_ver As UShort Public Shared com1_fw_ver As UShort Public Shared com2_fw_ver As UShort Public Shared index As VariantType Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOpen.Click If OpenFileDialog1.ShowDialog() = DialogResult.OK Then 'Dim sr As New System.IO.StreamReader(OpenFileDialog1.FileName) Dim fs As New System.IO.FileStream(OpenFileDialog1.FileName, IO.FileMode.Open) Dim br As New System.IO.BinaryReader(fs) fs.Position = 0 'sets the position to the beginning of the stream 'While Not fs.EndOfStream magic_number = br.ReadUInt16() find_next_magic_number(br) flag_block1 = br.ReadUInt64 flag_block2 = br.ReadUInt64 bytes = br.ReadBytes(10) serial_no = System.Text.Encoding.UTF8.GetString(bytes).ToString dig_fw_ver = br.ReadUInt16 lcd_fw_ver = br.ReadUInt16 sd_fw_ver = br.ReadUInt16 com1_fw_ver = br.ReadUInt16 com2_fw_ver = br.ReadUInt16 RichTextBox1.AppendText(magic_number & ",") RichTextBox1.AppendText(flag_block1 & ",") RichTextBox1.AppendText(flag_block2 & ",") RichTextBox1.AppendText(serial_no & ",") RichTextBox1.AppendText(dig_fw_ver & ",") RichTextBox1.AppendText(lcd_fw_ver & ",") RichTextBox1.AppendText(sd_fw_ver & ",") RichTextBox1.AppendText(com1_fw_ver & ",") RichTextBox1.AppendText(com2_fw_ver & vbCrLf) br.Close() fs.Close() ' byte (8 bit) ' ushort (16 bit) ' uinteger (32 bit) End If End Sub ' finds next magic number setting the position in the current ' stream to the first byte after the magic number. ' Returns the number of bytes skipped to get to the magic number ' or 0 if no bytes had to be skipped, -1 if end of file was reached, ' -2 or less if bytes were skipped until the end of file. Public Shared Function find_next_magic_number(ByRef br As System.IO.BinaryReader) As Integer Dim skipcount As Integer = 0 Dim magicfound As Integer = 0 Dim test As Integer = 0 While ((br.PeekChar() <> -1) And (magicfound = 0)) If br.ReadByte() = &H55 Then If (br.PeekChar() <> -1) And br.ReadByte() = &HAA Then magicfound = 1 Else skipcount = skipcount + 1 End If Else skipcount = skipcount + 1 End If test = (br.PeekChar() <> -1) test = (Not magicfound) End While If (magicfound = 1) Then Return skipcount Else Return (skipcount - 1) End If End Function