Solved

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

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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

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…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

617 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