VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Caller ID in 15 sec

by Shareef Dana (2 Submissions)
Category: Miscellaneous
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Wed 7th September 2005
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Caller ID in 15 sec

Rate Caller ID in 15 sec



Public Call_Number As String
Private Sub Form_Load()
    With MSComm1
        .Settings = "9600, N, 8, 1" '// Baud, Parity, Data Bits, Stop Bits
        .CommPort = 2 '// Change to the port of your modem              

        If .PortOpen = False Then '// If the port is not already open
.PortOpen = True '// open it
End if
        
.RThreshold = 0
        .InputLen = 0
       
.Output = "AT#CID=1" & Chr(13) '// Send the modem the 
     '// appropriate AT command
  '// to enable the modem to 
  '// sit and wait for
  '// incoming calls and capture
  '// the caller id information
  '// Check the modem's documentation
  '// for the correct string
    End With
End Sub

Private Sub Form_Unload(Cancel As Integer)

    MSComm1.PortOpen = False '// Close the port when the 
'// program is closed
    
End Sub

Private Sub MSComm1_OnComm()
Dim Buffer As String '// Will hold the string
'// from the modem

'// I was having problems dealing with 
'// the returns and line feeds so I deleted
'// them from the Buffer
        
Buffer = Replace(MSComm1.Input, Chr(13), "")
Buffer = Replace(Buffer, Chr(10), "")
    
    GetCallerInfo (Buffer)
    
End Sub

Private Sub GetCallerInfo(Caller_Id_string As String)
        
             
        If InStr(Caller_Id_string, "NAME") > 0 Then
        
           Call_Name = Mid(Caller_Id_string, (InStr(Caller_Id_string, "NAME = ") + 7), _
                ((InStr(Caller_Id_string, "NMBR = ") - 7) - InStr(Caller_Id_string, "NAME = ")))
               
        End If
           
        If InStr(Caller_Id_string, "NMBR") > 0 Then
        
            Call_Number = Mid(Caller_Id_string, (InStr(Caller_Id_string, "NMBR = ") + 7))
              
        End If
           
               
        If Len(Call_Name) > 1 Or Len(Call_Number) > 1 Then

            Call Database_Update()
    
        End If


End Sub

Private Function Database_Update()

        Dim Command_Text As String

        Command_Text = "Insert Into tbl_Caller_Id (Call_Name, Call_Number)" & _
            "Values ('" & Call_Name & "', '" & Call_Number & "')"

        Dim myConnection As New ADODB.Connection
        
        myConnection.Open "Driver={SQL Server};" & _
                          "Server=localhost;" & _
                          "Database=mydb;" & _
                          "Uid=;" & _
                          "Pwd=;"
                          
        myConnection.Execute (Command_Text)

        myConnection.Close

        Call_Name = ""     '// Set the values back to nothing
        Call_Number = ""

End Function


Download this snippet    Add to My Saved Code

Caller ID in 15 sec Comments

No comments have been posted about Caller ID in 15 sec. Why not be the first to post a comment about Caller ID in 15 sec.

Post your comment

Subject:
Message:
0/1000 characters