Solved

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

Posted on 2009-07-07
5
206 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

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…
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.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

685 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