Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Dim s As String
With MSComm1
' First we initialize a few properties.
' Set the COM port number.
.CommPort = 1
' The communication settings. The values are:
' baud rate, parity, data bits, stop bits.
.Settings = "9600,n,8,1"
' Recieve and send thresholds, described below.
.RThreshold = 1
.SThreshold = 1
' Open COM1 and begin communications.
.PortOpen = True
' Send the string "some data" to the output buffer.
.Output = "some data"
' Get the current contents of the input buffer.
s = .Input
End With
Private Sub Form1_Load()
With MSComm1
.CommPort = 1
.Settings = "9600,n,8,1"
.RTSEnabled = True
.RThreshold = 1
.Handshaking = comNone
End With
OutputBox.Multiline = True
End Sub
' Dial a hard-coded phone number and wait for
' the modem to connect.
Private Sub Dial_Click()
With MSComm1
If .PortOpen Then
MsgBox "Port already opened."
Exit Sub
End If
.PortOpen = True
.Output = "+++"
.Output = "ATDT 5551234" & vbCrLf
OutputBox.Text = "Dialing 555-1234"
' Wait for the carrier detect signal, which
' indicates that the modem is connected.
Do Until .CDHolding
OutputBox.Text = OutputBox.Text & "."
DoEvents
Loop
End With
End Sub
' Hang up the modem.
Private Sub HangUp_Click()
OutputBox.Text = OutputBox.Text & "Hanging up."
With MSComm1
.Output = "+++"
.Output = "ATH0"
.PortOpen = False
End With
End Sub
' Send the text entered in the command box to the
' remote system, then clear the box.
Private Sub SendCmd_Click()
With MSComm1
If .PortOpen Then
.Output = CmdBox.Text & vbCrLf
CmdBox.Text = vbNullString
Else
MsgBox "Port is closed."
End If
End With
End Sub
Private Sub MSComm1_OnComm()
Select Case MSComm1.CommEvent
' Capture any incoming data and write
' it to the output box.
Case comEvSend
OutputBox.Text = OutputBox.Text & MSComm1.Input
' Capture changes in the carrier detect line.
' This will detect if the modem has been
'disconnected.
Case comEvCD
If Not MSComm1.CDHolding Then
HangUp_Click
OutputBox.Text = OutputBox.Text & "Disconnected."
End If
End Select
End Sub