Results 1 to 25 of 25

Thread: Caller ID

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Brooklyn NY USA
    Posts
    1,258

    Caller ID

    Here is the code needed to get caller ID
    VB Code:
    1. Option Compare Text
    2. Private Sub Form_Load()
    3.  
    4. MSComm1.CommPort = 3
    5. ' 9600 baud, no parity, 8 data, and 1 stop bit.
    6. MSComm1.Settings = "9600,N,8,1"
    7. ' Tell the control to read entire buffer when Input
    8. ' is used.
    9. MSComm1.InputLen = 0
    10. ' Open the port.
    11. MSComm1.PortOpen = True
    12. ' Send the attention command to the modem.
    13. MSComm1.Output = "ATZ" & Chr$(13) ' Ensure that
    14.  
    15.    Do
    16.       DoEvents
    17.    Buffer$ = Buffer$ & MSComm1.Input
    18.    Loop Until InStr(Buffer$, "OK" & vbCrLf)
    19.    
    20. Text1.Text = Text1.Text & MSComm1.Input
    21. ' the modem responds with "OK".
    22. ' Wait for data to come back to the serial port.
    23.    
    24. ' Read the "OK" response data in the serial port.
    25. ' Close the serial port.
    26. num = 1
    27. reselect:
    28. '
    29. Select Case num
    30. '
    31. Case 1
    32.     cidm = "AT%CCID=1"
    33. '
    34. Case 2
    35.     cidm = "AT#CID=1"
    36.  
    37. Case 3
    38.  
    39.     cidm = "AT+VCID=1"
    40.  
    41. Case 4
    42.     cidm = "AT#CC1"
    43.  
    44. Case 5
    45.     cidm = "AT*ID1"
    46.  
    47. End Select
    48.  
    49. MSComm1.Output = cidm & Chr$(13) ' Ensure that
    50.  
    51. Do Until MSComm1.InBufferSize
    52.  
    53.     DoEvents
    54. Loop
    55. 'Text1.Text = Text1.Text & MSComm1.Input
    56.  
    57. If InStr(1, MSComm1.Input, "Error", vbTextCompare) Then
    58.     num = num + 1
    59.     GoTo reselect
    60. End If
    61.  
    62. End Sub
    63.  
    64. Private Sub MSComm1_OnComm()
    65. On Error Resume Next
    66.  
    67. Dim InString As String
    68. ' Retrieve all available data.
    69. MSComm1.InputLen = 0
    70. 'Text1.Text = Text1.Text & "Dropped Phone" & vbCrLf
    71. ' Check for data.
    72.  
    73. If MSComm1.InBufferCount Then
    74.     ' Read data.
    75.     ww = MSComm1.Input
    76.     Text1.Text = Text1.Text & ww
    77.  
    78.     If ww Like "*Privacy*" Then
    79.      '   Data1.Recordset.AddNew
    80.         pos = InStr(1, ww, "Time=", vbTextCompare)
    81.         List1.AddItem Mid(ww, pos + 5, 11)
    82.      '   Data1.Recordset!Time = Mid(ww, pos + 5, 11)
    83.      '   Data1.Recordset!Name = "Private Caller"
    84.          List1.AddItem  "Private Caller"
    85.      '   Data1.Recordset.Update
    86.         Exit Sub
    87.     End If
    88.  
    89.     If ww Like "*NAME*" Then
    90.       '  Data1.Recordset.AddNew
    91.         pos = InStr(1, ww, "Time=", vbTextCompare)
    92.         List1.AddItem Mid(ww, pos + 5, 11)
    93.       '  Data1.Recordset!Time = Mid(ww, pos + 5, 11)
    94.         pos = InStr(1, ww, "Nmbr=", vbTextCompare)
    95.         List1.AddItem Mid(ww, pos + 5, 10)
    96.       '  Data1.Recordset!Number = Mid(ww, pos + 5, 10)
    97.         pos = InStr(1, ww, "Name=", vbTextCompare)
    98.        
    99.         nme = Mid(ww, pos + 5)
    100.  
    101.         If InStr(1, nme, ",") Then
    102.             pos = InStr(1, nme, ",")
    103.             fnme = Mid(nme, pos + 1)
    104.             nme = Mid(nme, 1, pos - 1)
    105.         End If
    106.  
    107.         List1.AddItem Trim(Trim(fnme) & " " & Trim(nme))
    108.       '  Data1.Recordset!Name = StrConv(Trim(Trim(fnme) & " " & Trim(nme)), vbProperCase)
    109.       '  Data1.Recordset.Update
    110.       '  Data1.Recordset.Requery
    111.     End If
    112.  
    113. End If
    114.  
    115. End Sub

    Add A list box and a TextBox. You could also use a database to store the numbers.

  2. #2
    Good to know.

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Brooklyn NY USA
    Posts
    1,258
    Thanks. This does thru AT Commands. Still trying to figure out TAPI.

    Hope to get it soon.

  4. #4
    Are you talking to yourself?

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Brooklyn NY USA
    Posts
    1,258
    Part of being a programmer.
    talking to your self

  6. #6
    Well, I guess somebody later on could benefit from the monologue.

  7. #7
    Fanatic Member BrianHawley's Avatar
    Join Date
    Aug 2001
    Location
    Saudi Arabia
    Posts
    796

    What modem?

    I guess you need a modem that supports Caller ID. Do most modern modems provide that now? Is Caller ID a universal standard, or are modems country specific?
    Brian
    (Fighting with the RightToLeft bugs in VS 2005)

  8. #8
    Member king_willy's Avatar
    Join Date
    Sep 2001
    Location
    Sydney
    Posts
    61
    I just tried this code and well, it partially works, but all i get is the word ring|||ring|||ring|||| etc, I live in Australia, is there anything i should add to let it pick up phone numbers?

    Aus phone numbers ar set up like:

    Normal phone 002 98733277

    mobile 04173756978

    anything that can be helped???

  9. #9

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Brooklyn NY USA
    Posts
    1,258
    First you need i modem that supports caller id. to check that check if it returns ok in any case.
    do something like this.
    VB Code:
    1. Private Sub Form_Load()
    2.  
    3. MSComm1.CommPort = 3
    4. ' 9600 baud, no parity, 8 data, and 1 stop bit.
    5. MSComm1.Settings = "9600,N,8,1"
    6. ' Tell the control to read entire buffer when Input
    7. ' is used.
    8. MSComm1.InputLen = 0
    9. ' Open the port.
    10. MSComm1.PortOpen = True
    11. ' Send the attention command to the modem.
    12. MSComm1.Output = "ATZ" & Chr$(13) ' Ensure that
    13.  
    14.    Do
    15.       DoEvents
    16.    Buffer$ = Buffer$ & MSComm1.Input
    17.    Loop Until InStr(Buffer$, "OK" & vbCrLf)
    18.    
    19. Text1.Text = Text1.Text & MSComm1.Input
    20. ' the modem responds with "OK".
    21. ' Wait for data to come back to the serial port.
    22.    
    23. ' Read the "OK" response data in the serial port.
    24. ' Close the serial port.
    25. num = 1
    26. reselect:
    27. '
    28. Select Case num
    29. '
    30. Case 1
    31.     cidm = "AT%CCID=1"
    32. '
    33. Case 2
    34.     cidm = "AT#CID=1"
    35.  
    36. Case 3
    37.  
    38.     cidm = "AT+VCID=1"
    39.  
    40. Case 4
    41.     cidm = "AT#CC1"
    42.  
    43. Case 5
    44.     cidm = "AT*ID1"
    45.  
    46. End Select
    47.  
    48. MSComm1.Output = cidm & Chr$(13) ' Ensure that
    49.  
    50. Do Until MSComm1.InBufferSize
    51.  
    52.     DoEvents
    53. Loop
    54. 'Text1.Text = Text1.Text & MSComm1.Input
    55.  
    56. If InStr(1, MSComm1.Input, "Error", vbTextCompare) Then
    57.     num = num + 1
    58.     GoTo reselect
    59. End If
    60.  
    61. If InStr(1, MSComm1.Input, "ok", vbTextCompare) Then
    62.    
    63.     Msgbox "This modem supports caller ID"
    64. End If
    65.  
    66. End Sub

  10. #10
    chenko
    Guest
    ahhhhhhhhh, i can have some nice fun with that also... I guess the phone on the line doesnt ring?

  11. #11
    Hyperactive Member
    Join Date
    May 2001
    Location
    Beirut, Lebanon
    Posts
    318
    Hello,

    This doesn't have to do with "Caller ID", but it seems that you guys know how to use AT commands.

    Question: if my program dials a number, how can I know when the party being called answers?


    Thanks

  12. #12
    Member king_willy's Avatar
    Join Date
    Sep 2001
    Location
    Sydney
    Posts
    61
    hmmmmm, handy thanx

  13. #13
    Addicted Member
    Join Date
    May 2002
    Posts
    230
    I tried this code but when I try to run it I get a '424' object required error and it goes to this part of the code

    MSComm1.CommPort = 3

    do I need to dim MSComm1 or set something to that? All I saw was I need a list box and textbox...

  14. #14

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Brooklyn NY USA
    Posts
    1,258
    You need to add a Microsoft Communication Control.

  15. #15
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    man this code is pretty cool... i would like to set up a full phone system program on my comp.. i would if I hadn't yanked my modem out to make room for other stuff... oh well..

    you need to be a subscriber to called id from the phone company first correct?

  16. #16

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Brooklyn NY USA
    Posts
    1,258
    Yes you need to suscribe.

    If you want to make a complete phone application i would recomment you dont use AT Commands. you should use the windows API.

  17. #17
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    well i don't even have a modem now so it would not do me much good.. i replaced it with my SB Audigy EX Plat card.. it takes up 2 slots

  18. #18
    Addicted Member
    Join Date
    May 2002
    Posts
    230
    what is a Microsoft Communication Control. how do I do that???

  19. #19
    Hyperactive Member hassa046's Avatar
    Join Date
    May 2001
    Location
    Venlo, The Netherlands
    Posts
    336

    Re: Caller ID

    First try to know for sure you guys don't have dtmf tones from your phonecompany.
    Here in Holland we do.
    I have stubberd with this problem for a year and discovered that alsmost all modems don't support this function.

    Also this service has to be provided by your serviceprovider, otherwise it won't work also.

    Greetzzz
    Better to regret things you did, than those you didn't
    International Intelligence

  20. #20
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Caller ID

    Here's a post i made today. Don't know about Holland, but it does work in the US on most modems.

    http://www.vbforums.com/showpost.php...04&postcount=8

  21. #21
    Frenzied Member longwolf's Avatar
    Join Date
    Oct 2002
    Posts
    1,343

    Re: Caller ID

    Looks cool

    But i noticed that you added this to the code.

    VB Code:
    1. If InStr(1, MSComm1.Input, "ok", vbTextCompare) Then
    2.        
    3.         MsgBox "This modem supports caller ID"
    4.     End If


    BUT, won't this loop go on forever if the modem doesn't support caller ID?

    VB Code:
    1. Do
    2.          DoEvents
    3.          Buffer$ = Buffer$ & MSComm1.Input
    4.     Loop Until InStr(Buffer$, "OK" & vbCrLf)

  22. #22
    Frenzied Member longwolf's Avatar
    Join Date
    Oct 2002
    Posts
    1,343

    Re: Caller ID

    TSur,

    Click the Project menu> Components

    then find "Microsoft Comm Control", checkmark it, then add the new telephone control/icon to your project

  23. #23
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Caller ID

    You do realize that this thread is very old, don't you?

    Were you talking to me about the "OK" loop?

  24. #24
    Frenzied Member longwolf's Avatar
    Join Date
    Oct 2002
    Posts
    1,343

    Re: Caller ID

    dglienna ,

    No, i didn't notice the age on the post, lol

    And the question was ment of shragel .
    It looks like the modem test lines he added would never be reached by a modem that couldn't do caller id.

  25. #25
    Junior Member
    Join Date
    May 2005
    Posts
    17

    Re: Caller ID

    I'd only use the MSComm control for non-modem serial devices or wiggling the handshake pins to do bitwise I/O (i.e. home brew IR remote control / learning).

    Few modems support Caller ID, DTMF detection etc and AT command sets vary widly. USB modems may not even be compatible twith Comm port access.

    TAPI is better for phone applications. However the MSComm control will let not just do serial I/O but the Break command lets you turn on/off TX pin, two other o/p pins and two input pins all addressable individually can be used for any thing you want to control (i.e. relay via transistor, diode and 10K resistor) or input from (opto isolator, switch, etc). You can make a simple burgler alarm, heating controller, IR controll / learner and may other things.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width