Viewing Hex in a ML TextBox

Zenerdiode

Active Member
Licensed User
Please be critical of the attached code. I'm wanting to analyse data telegrams by looking at the individual bytes - so this is the hex viewer of my work in progress. You see I take the string, work out how long it is and build each line of a Multiline TextBox.

Is this the best way to deal with this? The text box is like having a 'Single Document Interface' type form, but I've never known the correct way to deal with them. I mean, say the IDE for Basic4PPC. Its not one long string being displayed in a textbox - or is it? I even thought about having a large table, with the hex and characters in individual cells but then I'm not that sure how to scroll it. It would help if I needed to modify some bytes (but at the moment I only need a viewer)

Then the code to provide a hex representation of the bytes. Have I overlooked a library that may be able to handle it better than my attempt?

Its working for what I want it to do but my eutopia would be to set byte sequences and have them displayed in a different colour. Would I have to do that in HTML?

Requires FormLib.dll
 

Attachments

  • HexAnalyser.sbp
    2.6 KB · Views: 195

agraham

Expert
Licensed User
Longtime User
I mean, say the IDE for Basic4PPC. Its not one long string being displayed in a textbox - or is it?
Effectively yes.

Then the code to provide a hex representation of the bytes. Have I overlooked a library that may be able to handle it better than my attempt?
My BytesConverter library will do it but your way is good enough. You should note however that Asc() can return values of higher than 256 as characters are 16 bit Unicode characters in B4ppc strings. However it's OK for testing but your final code may need to read the bytes from the file into a byte array using BinaryFile.ReadBytes to avoid the transformation into 16 bit characters.

Its working for what I want it to do but my eutopia would be to set byte sequences and have them displayed in a different colour. Would I have to do that in HTML?
On the desktop you could use my RichTextDesktop library, on the device it would have to be HTML and my WebBrowser library.
 
Top