Solved

Edit byte in file

Posted on 2010-11-23
4
291 Views
Last Modified: 2012-05-10
So I have no problem reading the byte in this file I want, but I'm having difficulty editing it with VB.NET.

(For example) The value is 0B in hex and I have a combobox populate with possible replacements for the byte - say 9.  They are in decimal format and I want them to be able to be selected, then switched to hex format and replace the byte that I have already previously read.  So in this instance, 0B becomes 09 after 9 is selected in the combobox and a button is pushed.

Do I need to read the byte first to know which one to replace?

Any help is appreciated!
0
Comment
Question by:jasgiv1122
  • 3
4 Comments
 
LVL 29

Accepted Solution

by:
nffvrxqgrcfqvvc earned 250 total points
ID: 34200566
You can use either BitConverter Class ToString() method or X2 hexadecimal format specifier.

BitConverter Class
http://msdn.microsoft.com/en-us/library/system.bitconverter.aspx
Debug.Print(CByte(ComboBox1.SelectedItem).ToString("X2"))

Open in new window

0
 
LVL 2

Author Comment

by:jasgiv1122
ID: 34200632
How can I determine where in the file it puts the formatted number?  I need to read the first byte in the file and replace it with my newly formatted text.

Thanks
0
 
LVL 2

Assisted Solution

by:jasgiv1122
jasgiv1122 earned 0 total points
ID: 34201332
I figured the rest out. Thanks
0
 
LVL 2

Author Closing Comment

by:jasgiv1122
ID: 34224727
Answered half of my question.  I used Writebyte to solve the rest of my problem.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question