Solved

vb.net hex to file

Posted on 2009-04-10
5
299 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 500 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Adjust the codes 3 65
search by any word in column 5 29
Help with modifying xml file using VB.NET 5 13
ErrorKind in crystal reprot VB.Net 1 19
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
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 …

710 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