Option Compare Text
Private Sub Form_Load()
MSComm1.CommPort = 3
' 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 = "ATZ" & Chr$(13) ' Ensure that
Do
DoEvents
Buffer$ = Buffer$ & MSComm1.Input
Loop Until InStr(Buffer$, "OK" & vbCrLf)
Text1.Text = Text1.Text & MSComm1.Input
' the modem responds with "OK".
' Wait for data to come back to the serial port.
' Read the "OK" response data in the serial port.
' Close the serial port.
num = 1
reselect:
'
Select Case num
'
Case 1
cidm = "AT%CCID=1"
'
Case 2
cidm = "AT#CID=1"
Case 3
cidm = "AT+VCID=1"
Case 4
cidm = "AT#CC1"
Case 5
cidm = "AT*ID1"
End Select
MSComm1.Output = cidm & Chr$(13) ' Ensure that
Do Until MSComm1.InBufferSize
DoEvents
Loop
'Text1.Text = Text1.Text & MSComm1.Input
If InStr(1, MSComm1.Input, "Error", vbTextCompare) Then
num = num + 1
GoTo reselect
End If
End Sub
Private Sub MSComm1_OnComm()
On Error Resume Next
Dim InString As String
' Retrieve all available data.
MSComm1.InputLen = 0
'Text1.Text = Text1.Text & "Dropped Phone" & vbCrLf
' Check for data.
If MSComm1.InBufferCount Then
' Read data.
ww = MSComm1.Input
Text1.Text = Text1.Text & ww
If ww Like "*Privacy*" Then
' Data1.Recordset.AddNew
pos = InStr(1, ww, "Time=", vbTextCompare)
List1.AddItem Mid(ww, pos + 5, 11)
' Data1.Recordset!Time = Mid(ww, pos + 5, 11)
' Data1.Recordset!Name = "Private Caller"
List1.AddItem "Private Caller"
' Data1.Recordset.Update
Exit Sub
End If
If ww Like "*NAME*" Then
' Data1.Recordset.AddNew
pos = InStr(1, ww, "Time=", vbTextCompare)
List1.AddItem Mid(ww, pos + 5, 11)
' Data1.Recordset!Time = Mid(ww, pos + 5, 11)
pos = InStr(1, ww, "Nmbr=", vbTextCompare)
List1.AddItem Mid(ww, pos + 5, 10)
' Data1.Recordset!Number = Mid(ww, pos + 5, 10)
pos = InStr(1, ww, "Name=", vbTextCompare)
nme = Mid(ww, pos + 5)
If InStr(1, nme, ",") Then
pos = InStr(1, nme, ",")
fnme = Mid(nme, pos + 1)
nme = Mid(nme, 1, pos - 1)
End If
List1.AddItem Trim(Trim(fnme) & " " & Trim(nme))
' Data1.Recordset!Name = StrConv(Trim(Trim(fnme) & " " & Trim(nme)), vbProperCase)
' Data1.Recordset.Update
' Data1.Recordset.Requery
End If
End If
End Sub