Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2009-07-07
5
Medium Priority
?
213 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 21

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 21

Accepted Solution

by:
alainbryden earned 1000 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 21

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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

824 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