Solved

How to convert a alpha numeric string into Hex

Posted on 2009-07-13
6
794 Views
Last Modified: 2012-05-07
I have a alpha numeric serial number "0013a200402c4bca" and I want to convert it into hex?
any ideas?
0
Comment
Question by:cmdolcet
6 Comments
 
LVL 18

Expert Comment

by:Ajay Sharma
ID: 24839004
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 24839021
Try with the following:

Dim test as String = "0013a200402c4bca"
Dim num as Int64
num = Convert.ToInt64(test, 16)
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 24839029
Notice that a regular Integer (Int32) cannot contain such large number.
0
Industry Leaders: 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!

 

Author Comment

by:cmdolcet
ID: 24839152
jaime_olivares, the alpha string im trying to convert i want it in an array

so the string"0013a200402c4bca"
how can i break this up into array section
(0) = 00
(1)=13
(2)=a2
(3)=00
(4)=40
(5)=2c
(6)=4b
(7)=ca

then convert this to hex value?
Sorry i should have been clear when i originally asked the question
0
 
LVL 8

Expert Comment

by:bhmahler
ID: 24840719
That value is already in hex. It is an 8 bytes int64  if you want to get the value of it numerically you can use something like this.

Dim result As Int64 = Int64.Parse("0013a200402c4bca", Globalization.NumberStyles.HexNumber)

Open in new window

0
 
LVL 8

Accepted Solution

by:
bhmahler earned 500 total points
ID: 24840769
You can also use bitconverter to break the number back into the hex string
BitConverter.ToString(BitConverter.GetBytes(result), 0))

Open in new window

0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Complex SQL statement in VB.NET 7 39
Access Schema 6 45
How do I copy a form and rename it in VS2015 2 21
Copying from a network share 3 25
This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
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…

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