how to send characters to com port..

is very simple in another language..

of course, in VB, too.

But in vb, i don't know how to send

above 128.(0xfe, 0xff, 0x80..etc)

thank you..



LVL 1
can9999Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TimCotteeHead of Software ServicesCommented:
These characters can be represented by chr$(128) etc so a string to the comm port can be

MSComm1.Output "This is a message string including" & chr$(128) & " and other odd things such as " & chr$(241)

0
can9999Author Commented:
Please, try this..

MsgBox "{" & chr$(128) & "}"

you can see 128th character between "{ " and "}"

ok ,, next ..

MsgBox "{" & chr$(129) & "}"

you can't see any characters besides "{".

What do you think about this problem ?

.....

thank you !
0
TimCotteeHead of Software ServicesCommented:
This is true, it does not necessarily mean that the characters have not been sent to the serial port though. An alternative method is to use a byte array to send binary data.

An example of this is shown below, add an mscomm control and a command button to a new form. Run it and click the command button. The values in the msgbox display will be garbage but the correct characters will in fact be output to the serial port.

You could extend this to send both character data and byte data to the port either by parsing your character strings into a byte array or by using a sequence of output commands.

Dim aryOutput() As Byte

Private Sub Command1_Click()
    ReDim Preserve aryOutput(10)
    For intCount = 0 To 9
        aryOutput(intCount) = (128 + intCount)
    Next
    MsgBox (aryOutput)
    MSComm1.PortOpen = True
    MSComm1.Output = aryOutput
    MSComm1.PortOpen = False
End Sub
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.