MSComm Control

  • Thread starter Thread starter Jason James
  • Start date Start date
J

Jason James

Hi all,

does anyone have the faintest idea how t send ASCII(0), not
the ascii of the number 0 (48), but actually ascii(0) to the com
port using VB.Net? I can send arrays of bytes or string, but the
control seems to interpret them as the ascii value, and not the
actual value. For example, if I send

MsComm1.output = 27

I want is to send ascii(27) not 50, followed by ascii(55).

Many thanks for your help.

Jason.
 
Isn't it always the way, right after you post a message, the answer
pops straight into your head:

Dim outBuf() As Byte
outBuf = System.Text.UTF8Encoding.UTF8.GetBytes(Chr(0))
MSComm1.Output = outBuf

This works great and uses all 8 bits in the byte.

Thanks.
 
Hi,

You may be making it more complicated than necessary.

Dim Buffer(0) As Byte

Buffer(0) = 0

If AxMSComm1.PortOpen = False Then AxMSComm1.PortOpen = True

AxMSComm1.Output = Buffer


You may want to download DesktopSerialIO from my homepage. It is free, and
it is easier to work with and distribute than MSComm. I also have example
code in my book that might be helpful.

Dick

--
Richard Grier (Microsoft Visual Basic MVP)

See www.hardandsoftware.net for contact information.

Author of Visual Basic Programmer's Guide to Serial Communications, 4th
Edition ISBN 1-890422-28-2 (391 pages) published July 2004. See
www.mabry.com/vbpgser4 to order.
 
Dick,

thanks for the info. I'll be sure to give it a try when I get a moment.

Regards,

Jason.
 
Back
Top