|
-
Oct 4th, 2000, 07:45 AM
#1
Thread Starter
New Member
Hello,
I have a problem to receive binary data from a rs232 device which is connected to my serial port. I receive only strange letters en symbols but I want to receive binary data. I have tried a couple of codes which are posted on this forum but it still don't work.
With a shareware program to receive serial data I can read the data perfect, why can't I do it with visual basic.
Thanks for your help.
-
Oct 4th, 2000, 09:27 AM
#2
Guru
I hate to break it to you, but the strange letters and symbols are the binary data. 
If it is in a string, then you can copy it to a byte array using the StrConv function:
Code:
Dim sData As String
Dim btData() As Byte
' sData receives the binary data here
btData = StrConv(sData, vbFromUnicode)
Then, you can use the btData as a byte array, and read the bytes from it, or do whatever you want to do with it.
-
Oct 4th, 2000, 01:52 PM
#3
Thread Starter
New Member
how to use a binary array
Thank you for your reply.
I only don't know how to read the data form a binary array.
I have tested the function
btData = StrConv(sData, vbFromUnicode)
but I don't can read the data of that array.
How can I display on my screen and
how can I use the data in the array.
I want to test of I different data receive then 00000000.
Greetings.
-
Oct 4th, 2000, 02:02 PM
#4
Guru
Try this, to read data from the byte array and print it to the debug window:
Code:
Dim I As Integer
Dim sData As String
Dim btData() As Byte
Something ' sData receives data here
btData = StrConv(sData, vbFromUnicode)
For I = LBound(btData) To UBound(btData)
Debug.Print Hex(btData(I)) & " ";
Next
Debug.Print
The data will appear in the Immediate window.
If you don't see it (although you really really should!) then press Ctrl+G and it should appear.
-
Nov 27th, 2000, 04:40 PM
#5
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
|