|
-
Feb 18th, 2020, 05:51 AM
#1
Thread Starter
Junior Member
Should vb6 Strings be converted to byte arrays when using Com port communication?
Is it good practice to always convert a vb6 string to a byte array when using Com.output?
Would a string that was converted to a byte array like this:
Code:
Dim Sometext As String
Dim b() As Byte
Sometext = "Hello World"
b = StrConv(Sometext ,vbFromUnicode)
Be a better approach than simply do this:
Code:
Dim Sometext As String
Sometext = "Hello World"
Com.output = Sometext
The problem i'm facing is that 98% of commands work. But the device i send commands to, also has an 'internal hardware' that commands can be sent to, to do specific operations. These 'Specifics' dont work, or fail 99.8% of the time (specific number, but kinda accurate)
It doesn't work on my machine using vb6, but it does work on the manufacturer's machine, using .net
If we 'sniff' the data (using a 3rd party serial port monitor), everything seems to be exactly as we are sending it. ( Although it doesn't work here, and it DOES work over there.)
So to exclude the hardware being the problem, we've sent the whole package to the manufacturer. And using our hardware it works there, while it didn't over here.
I've found a thread ,where this was sort of discussed and it sparked the idea to me: http://www.vbforums.com/showthread.p...-mscomm-output
Since i'm new to Vb6 but really into it, and it's 'Part of the job', i need to learn myself a consistent way of doing this.
I don't want to run into incompatibility issues in the future. Especially when i'm working with newer hardware, that might internally not be able to handle a vb6 string variable if sent in unicode as per example 2.
Which way would be the most reliable way, and could my issue be related to it?
Tags for this Thread
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
|