Solved

vb.net hex to file

Posted on 2009-04-10
5
300 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

624 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