Hope this make sense to you.
Code:
Option Explicit
Private ACK As Boolean
Private str As String
Private Buff As String
Private Sub Form_Load()
With MSComm1
If Not .PortOpen Then
'Initialize the Comm
.CommPort = 1
.Settings = "9600,n,8,1"
.InputLen = 1
'Open the Comm port
.PortOpen = True
'Reset the Modem
ACK = False
.Output = "ATZ" & vbCr
'Wait for the "OK" from modem
Do While Not ACK
DoEvents
Loop
'Reset the flag
ACK = False
'Dial the phone number
.Output = "ATDT 123456789" & vbCr
'Wait for the "OK" from modem
Do While Not ACK
DoEvents
Loop
MsgBox "Wait for the receive party to pickup the call."
Else
MsgBox "Comport not available."
End If
End With
End Sub
Private Sub MSComm1_OnComm()
Select Case CommEvent
Case comEvReceive
ProcessData
End Select
End Sub
Private Sub ProcessData()
str = str & MSComm1.Input
Do While str <> ""
'Search for the "OK" from Modem
If InStr(1, Buff, "OK", vbTextCompare) <> 0 Then
Buff = ""
ACK = True
End If
Buff = Mid(str, 1, 1)
str = Mid(str, 1)
DoEvents
Loop
End Sub