Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MSCOMM .Output Question

Status
Not open for further replies.

KenG

Technical User
Mar 20, 2000
67
0
0
US
I want to transfer data out from a Access DB using a COM port. Currently I do this using HyperTerminal (Xmodem) using Transfer... Send File... to transfer a text file.
(But not using Transfer... Send Text File..)

I'd like to use the MSCOMM ActiveX control a loop through a recordset instead of manually creating text files and sending them one by one.

Using MSCOMM I can receive OK. I just can't send anything.
My guess is that I need to send each record as a binary array. If this is true, how do I do it?
 
You have to declare the input mode as binary, you should be able to send text or binary info. But to use binary mode you have to use a byte array and you can send hex or Decimal data.

dim ByteArray(2) as Byte

MSComm.InputMode = comInputModeBinary

ByteArray(0) = &H2
ByteArray(1) = &H5
ByteArray(2) = &H3

MSComm.Output = ByteArray()

I've used this to communicate with batch handhelds I used the asc(char) to convert each character to Decimal.
 
Thank you for the reply,
I've only used arrays once, so I'm not very familiar with the concept. And I've never used the Byte data type. So if my question seems a little elementary you'll know why.

Wouldn't I want to dynamically delare the array? I don't know the exact number of characters I'm going to use in the MSComm.Output statement.

Now for the really dumb question; What does &H2 mean? I can't find anyting in my reference books about the use of '&' in this context.

Thanks in advance for any response.
 
Once you know what you are sending you can

ReDim ByteArray(len(sSendData)).

The &H tells VB that you are using hex.

&H2 = STX (Start of text)
&H3 = ETX (End of text)
...
You can look them up on a ASCII table they are used to tell when you have started sending a message or ending a message. There are many others.
 
Thanks for the reply.
I think I've got figured out now.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top