Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

vb.net hex to file

Posted on 2009-04-10
5
Medium Priority
?
314 Views
Last Modified: 2013-11-26
im trying to convert in vb.net

10 43 74 98 F0 9A 7D CB C1 FA 7A A1 01 FE 97 6E
40 30 0D 06 09 2A 86 48 86 F7 0D 01 01 05 05 00 ect

what do i need to do to take 10 and wite that to file ...

the code below will not work as exptected ...
if i toss in the 00 it will write 00 but if i toss in 11 it will write 0B
any ideas how to fix this problem

thanks in advance.
Dim byteData As Byte = Byte.Parse("00")
Dim oFileStream As System.IO.FileStream
oFileStream = New System.IO.FileStream("bytes.dat", System.IO.FileMode.Append)
oFileStream.WriteByte(byteData)
oFileStream.Close()

Open in new window

0
Comment
Question by:03671328
  • 3
  • 2
5 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 24129737
You should be able to do this:

Dim byteData As Byte = 11

0
 
LVL 1

Author Comment

by:03671328
ID: 24129786
tryed that comes back as 0B
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 24129789
0B (hex) is 11 (decimal), so what are you REALLY trying to do here?
0
 
LVL 1

Author Comment

by:03671328
ID: 24129853
i'm trying to write the hex? to the file
i'm trying to take hex and write exactly that to a file.

if i get a string of 11 20 10 18 11 22 22 34
i want it to write just that.
i can split it up just not sure how to write exactly what is there.
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 2000 total points
ID: 24130039
You need to split those pairs up by space, convert the hexadecimal values to decimal, and then use WriteByte with the decimal value.

Simple approach for hex to decimal:

    Dim n As Integer = CInt("&H" & text)

String split by space:

   Dim s As String = text.Split(" ")
0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…

876 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