#HELP with Com Port VB
3 messages in this thread
Need HELP with Com port in V Basic using VBasic i want to communicate
between my computer and Ham radio transceiver.I can open the the com port
and I can send info to the radio But here is my problem. This is the way it
is done in QBasic
Open "com1 " etc
print#1, chr$(0);chr$(15)
this instructs the radio to sent back 75 bytes to the computer.
in using QBasic this received the info B4= input(loc(1),#)
the above line is junk it should read b$=input$(loc(1)#) for I = 1 to
len(b$) b=mid$(b$,i,1):print b$ then i can process the bytes.How can this
input$ from the com port be done in VBasic does any have any suggestions
would be greatly apreciated. Thanks Bob Kowaluk
There are 2 Replies.
Bob,
There are three ways to do communications in Visual Basic:
1. The least practical is to use OPEN with "COMn", because it
depends on the default settings the user has set, i.e., you
cannot specify the baud, parity, data and stop bits.
2. The hard way is to use the Windows API calls directly. There are
two or three examples of doing this in DL1 and/or DL5. (They
may still be in the MSLANG forum.)
3. The easy way is to use an add-on library, such as my company's
communications library. In addition to making it very easy to
send and receive data, we provide many file transfer protocols
including XMODEM, YMODEM, YMODEM-G, ZMODEM and CompuServe B+.
As a bonus, the two versions of our product (one for QB/PDS and
the other for VB) are about 95% code-compatible. That means
you can move code between the two platforms with only minor
changes (if any).
Mark
Hi Bob,
Mark is right about the way you can do COM with VB. If you have a simple
app that does not change any of the parameters of the COM port, you can do
the same thing you did in the QBASIC/QB programs:
Open "COM1" For Random As #1
Do
If Not EOF(1) Then
Modem$ = Input$(Loc(1),#1)
End If
Continue% = ProcessString%(Modem$)
Until Continue% = FALSE
Remember that the Open will not have any additional parameters that you had
in the QB environment.
Don FUnk