VB.Net binary reader of a QuickBooks binary file
by Mountain Computers Inc., Publication Date: Saturday, February 19, 2022
View Count: 630, Keywords: VB.Net, Read Binary, Quickbooks, Signature, Hashtags: #VB.Net #ReadBinary #Quickbooks #Signature
had to write a quick piece of code to read the first 1024 bytes of a QBW file to see the recovery code marker signature. it was MAUI now its something else; depending I guess on the QB version. had to use a fixed font called Consolas for windows 10 since other sans serif's did not work as expected in formatting for readability.
tip: to create some fast example text, launch word for windows, on a blank like type =rand() and press enter key. i did the 0 through 9 and A through F for the data.txt and data.dat is a copy of a QBW binary.
working on the API to access the QBW in a few. that will be fun. If you go out of bounds on the Bytes to Read and the Chr() function you will have to add some catch error handling and look at the debugger. I wanted something quick and fast to read a header. I adjusted the code to read more and handle a few of the uncertain hex and val and chr values in the byte read.
That was interesting and quick to create. see the REF1 at the bottom for reference to MAUI.
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If My.Computer.FileSystem.FileExists(TextBox1.Text) Then
Label3.Text = "Yes"
Debug.Print("file does not exist")
Label3.Text = "No"
Private Sub CheckQBWfile()
Using reader As New BinaryReader(File.Open(TextBox1.Text, FileMode.Open, FileAccess.Read))
' Loop through length of file.
Dim buf As String = ""
Dim buf2 As String = ""
Dim pos As Integer = 1
Dim length As Integer = reader.BaseStream.Length
Dim qbwposition As Integer = Val(TextBox2.Text)
While pos < qbwposition
Dim value As Integer = reader.ReadByte
buf = buf & Hex(value).PadLeft(2, "0") & " "
Select Case value
Case 32 To 127
buf2 = buf2 & Chr(value)
buf2 = buf2 & "."
If pos Mod 16 = 0 Then
ListBox1.Items.Add(Hex(pos - 16).PadLeft(8, "0") & ": " & buf & " | " & buf2)
buf = ""
buf2 = ""
pos += 1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Label1.Text = "Filename:"
Label2.Text = "File Exists?"
Label3.Text = "?"
Label4.Text = "Bytes to Read:"
ListBox1.Font = New Drawing.Font("Consolas", 12, FontStyle.Regular)
TextBox1.Text = "data.dat"
TextBox2.Text = "1024"
Button1.Text = "Read File"
more to come...
if you found this article helpful, consider contributing $10, 20 an Andrew Jackson or so..to the author. more authors coming soon
FYI we use paypal or patreon, patreon has 3x the transaction fees, so we don't, not yet.
© 2023 myBlog™ v1.1 All rights reserved. We count views as reads, so let's not over think it.