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