Click to See Complete Forum and Search --> : how to read from the serial port
pan
Nov 12th, 1999, 04:29 PM
how can i read from the serial port?
does it have an interrupt?
Adrian_H
Nov 12th, 1999, 07:18 PM
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
pan
Nov 12th, 1999, 07:38 PM
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
Adrian_H
Nov 15th, 1999, 09:33 PM
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
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.