|
-
Sep 30th, 2000, 11:16 PM
#1
Thread Starter
Lively Member
This is a simple question, I've tried to get it to work, but failed, so now I'm asking the guru's
What code is needed to be able to pass information through a serial port, and what command actually passes the information or string?
Any information would be helpful.
Thanx.
-
Oct 1st, 2000, 12:10 AM
#2
Hyperactive Member
From the MS Help pages on MSComm Control
Slightly modified, and not at all complete to handle input/output, but it is a start for you..
Code:
' on a form with a MSComm constol, textbox and command button...
' I commented out the stuff relating to talking to a modem
' don't forget to specify the type of serial handshaking as well. Default is none.
Option Explicit
Private Sub Command1_Click()
MSComm1.Output = Text1.Text
End Sub
Private Sub Form_Load()
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 = "ATV1Q0" & Chr$(13) ' Ensure that
' the modem responds with "OK".
' Wait for data to come back to the serial port.
' Do
' DoEvents
' Buffer$ = Buffer$ & MSComm1.Input
' Loop Until InStr(Buffer$, "OK" & vbCrLf)
' Read the "OK" response data in the serial port.
End Sub
Private Sub Form_Unload(Cancel As Integer)
MSComm1.PortOpen = False
' Close the serial port.
End Sub
Private Sub MSComm1_OnComm()
' do something in here whenever the control detects a comms event
End Sub
Regards
-
Oct 1st, 2000, 10:10 PM
#3
Thread Starter
Lively Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|