Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
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.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
A short film showing how OnPage and Connectwise integration works.

929 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

21 Experts available now in Live!

Get 1:1 Help Now