|
-
Sep 16th, 2001, 09:31 PM
#1
Thread Starter
Frenzied Member
Caller ID
Here is the code needed to get caller ID
VB Code:
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
Add A list box and a TextBox. You could also use a database to store the numbers.
-
Sep 16th, 2001, 09:32 PM
#2
-
Sep 16th, 2001, 09:40 PM
#3
Thread Starter
Frenzied Member
Thanks. This does thru AT Commands. Still trying to figure out TAPI.
Hope to get it soon.
-
Sep 16th, 2001, 09:41 PM
#4
Member
Are you talking to yourself?
-
Sep 16th, 2001, 09:43 PM
#5
Thread Starter
Frenzied Member
Part of being a programmer.
talking to your self
-
Sep 16th, 2001, 09:44 PM
#6
Member
Well, I guess somebody later on could benefit from the monologue.
-
Sep 17th, 2001, 12:28 AM
#7
Fanatic Member
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)
-
Sep 17th, 2001, 01:57 AM
#8
Member
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???
-
Sep 17th, 2001, 03:49 AM
#9
Thread Starter
Frenzied Member
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:
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
If InStr(1, MSComm1.Input, "ok", vbTextCompare) Then
Msgbox "This modem supports caller ID"
End If
End Sub
-
Sep 17th, 2001, 04:04 AM
#10
ahhhhhhhhh, i can have some nice fun with that also... I guess the phone on the line doesnt ring?
-
Sep 17th, 2001, 04:33 AM
#11
Hyperactive Member
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
-
Sep 18th, 2001, 03:11 AM
#12
Member
-
Jun 5th, 2002, 12:26 PM
#13
Addicted Member
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...
-
Jun 5th, 2002, 01:21 PM
#14
Thread Starter
Frenzied Member
You need to add a Microsoft Communication Control.
-
Jun 5th, 2002, 01:27 PM
#15
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?
-
Jun 5th, 2002, 01:38 PM
#16
Thread Starter
Frenzied Member
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.
-
Jun 5th, 2002, 01:39 PM
#17
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
-
Jun 5th, 2002, 01:42 PM
#18
Addicted Member
what is a Microsoft Communication Control. how do I do that???
-
May 8th, 2005, 05:30 PM
#19
Hyperactive Member
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
-
May 8th, 2005, 05:42 PM
#20
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
-
May 9th, 2005, 12:55 AM
#21
Re: Caller ID
Looks cool
But i noticed that you added this to the code.
VB Code:
If InStr(1, MSComm1.Input, "ok", vbTextCompare) Then
MsgBox "This modem supports caller ID"
End If
BUT, won't this loop go on forever if the modem doesn't support caller ID?
VB Code:
Do
DoEvents
Buffer$ = Buffer$ & MSComm1.Input
Loop Until InStr(Buffer$, "OK" & vbCrLf)
-
May 9th, 2005, 01:00 AM
#22
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
-
May 9th, 2005, 01:01 AM
#23
Re: Caller ID
You do realize that this thread is very old, don't you?
Were you talking to me about the "OK" loop?
-
May 9th, 2005, 10:04 AM
#24
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.
-
May 9th, 2005, 11:55 AM
#25
Junior Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|