|
-
Aug 8th, 2004, 02:11 PM
#1
Thread Starter
Junior Member
Coverting a string to an array of bytes
Hi All,
I am having a hard time figuring out how to convert a string I get from the mscomm1.input to an array of bytes. I can't seem to figure out how to get a single byte from a string, then convert it to a byte. I can display the string I am receiving, but not as bytes.
I am recieiving data through a bluetooth link and the comm port from the robot I am working on. What I want to do is to get the mscomm1.input string length, then loop through taking one character of the string, converting it to a byte, then storing it in an array of bytes.
I just can't seem to figure out how to address individual characters in an array.
Thanks for the help,
Jonathan
www.madlabs.info
-
Aug 8th, 2004, 02:16 PM
#2
Humm humm... what is the current code you have for data input, before I start figuring this out?
-
Aug 8th, 2004, 02:57 PM
#3
Look into Chr & Asc functions in MSDN
-
Aug 8th, 2004, 02:58 PM
#4
Thread Starter
Junior Member
It goes something like this:
sData = MSComm1.Input
This results in a string with 4 characters. The data is coming from a robot.
Now, I want to convert the characters in the string to numbers, then store them in a byte array.
What I can't seem to do is address and retrive the individual characters of the string, then put them in an array.
Thanks,
Jonathan
-
Aug 8th, 2004, 03:20 PM
#5
Well, the easiest to go with:
VB Code:
Dim Buffer() As Byte
Buffer = StrConv(MSComm1.Input, vbFromUnicode)
Debug.Print "First byte: " & Buffer(0) & " | Number of bytes: " & (UBound(Buffer) + 1)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|