how can i read from the serial port?
does it have an interrupt?
Printable View
how can i read from the serial port?
does it have an interrupt?
Use the MSComm control that is shipped with VB. The VB help has reasonable examples of how to define, open and read from a serial port. However, if you need to read in Binary data, don't use the MS example. Respond back to this forum and I will post a code snippet for serial binary data reception.
Adrian
Hi:
first of all thanks...
I don't have the help files so I don't have
any example...
I need to read bits, 8 per transmission
if it's possible.
If you can give me the code or command
it will be a great help.
thanks
pan
Life's going to be rather hard without the Help files.
Below is a very basic example from the VB Help. I don't know whether I'm supposed to paste this Help snippet or not, apologies if this is the wrong thing to do.
Private Sub Form_Load ()
' Buffer to hold input string
Dim Instring As String
' Use COM1.
MSComm1.CommPort = 1
' 9600 baud, no parity, 8 data, and 1 stop bit.
MSComm1.Settings = "9600,N,8,1"
' Tell the control to read entire buffer when Input
' is used.
MSComm1.InputLen = 0
' Open the port.
MSComm1.PortOpen = True
' Send the attention command to the modem.
MSComm1.Output = "AT" + Chr$(13)
' Wait for data to come back to the serial port.
Do
DoEvents
Loop Until MSComm1.InBufferCount >= 2
' Read the "OK" response data in the serial port.
Instring = MSComm1.Input
' Close the serial port.
MSComm1.PortOpen = False
End Sub