Solved

How to convert a numerica serial number into an 8 bit array

Posted on 2009-07-07
5
203 Views
Last Modified: 2013-11-26
How can i convert a serial number (0013a200-402c4bca) into an 8 bit array like so

[0] x00
[1] x13
[2] xa2
[3] x00
[4] x40
[5] x2c
[6]x4b
[7]xca

How can I do this in vb?
0
Comment
Question by:cmdolcet
  • 3
  • 2
5 Comments
 
LVL 20

Expert Comment

by:alainbryden
ID: 24797922
If the serial number is stored in a string, use the .substring command to extract the pieces of the id.

--
Alain
0
 

Author Comment

by:cmdolcet
ID: 24797988
but how to i place it into the byte array?
0
 
LVL 20

Accepted Solution

by:
alainbryden earned 250 total points
ID: 24798213
Dim arrOfBytes As Byte(8)
arrOfBytes(0) = Byte.Parse(Serial.substring(1,2), Globalization.NumberStyles.HexNumber)
arrOfBytes(1) = Byte.Parse(Serial.substring(3,2), Globalization.NumberStyles.HexNumber)
arrOfBytes(2) = Byte.Parse(Serial.substring(5,2), Globalization.NumberStyles.HexNumber)
arrOfBytes(3) = Byte.Parse(Serial.substring(7,2), Globalization.NumberStyles.HexNumber)
arrOfBytes(4) = Byte.Parse(Serial.substring(10,2), Globalization.NumberStyles.HexNumber)
arrOfBytes(5) = Byte.Parse(Serial.substring(12,2), Globalization.NumberStyles.HexNumber)
arrOfBytes(6) = Byte.Parse(Serial.substring(14,2), Globalization.NumberStyles.HexNumber)
arrOfBytes(7) = Byte.Parse(Serial.substring(16,2), Globalization.NumberStyles.HexNumber)
--
Alain
0
 

Author Comment

by:cmdolcet
ID: 24802760
It says array bounds cannot appear in type specific
0
 
LVL 20

Expert Comment

by:alainbryden
ID: 24804030
Dim arrOfBytes(8) As Byte

I couldn't remember the exact syntax for VB.Net. I'm sure you figured it out on your own though.

--
Alain
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
This video discusses moving either the default database or any database to a new volume.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

757 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now