Re: Proper Command Code for a simple Phone Dialer
- From: That Guy <i_powers@xxxxxxxxxxx>
- Date: Wed, 19 Aug 2009 04:54:36 -0700 (PDT)
Hey Verne,
The only thing I don't understand because you did not post it is what
CleanPhoneNumber does. I am assuming it is a function used to remove
the "-" from a phone number when entered. if this is the case I would
again then assume it would work as follows:
CleanPhoneNumber(byval numbertoClean as string) as string
dim x,temp as integer
dim rString as string
for x = 1 to len(numbertoclean)
if strcomp(mid(numbertoclean,x,1),"-") <> 0 then
rString = rString & mid(numbertoclean,x,1
end if
next x
CleanPhoneNumber = rString
end function
This would give us a clean phone number.
At this point unless you are using a table to look up a name I am not
sure why you want the name of the person being dialed on the form but
if you wanted this make two text boxes, one named txtName and the
other named txtNumber.
Then you will need to make a combo to select the appropriate comm port
unless you know it and wan ti hard coded. In the example below I am
going to make it hard coded.
After that, and sssuming that your modem is old and "Hayes-Compatible"
use the following in your click event:
Private Sub cmdPhone_Click()
Const MAX_TRIES = 10000
Dim results As String
Dim num_tries As Long
Screen.MousePointer = vbHourglass
DoEvents
On Error GoTo Oops
' Try to give MSComm1 time to close.
If MSComm1.PortOpen = True Then MSComm1.PortOpen = False
DoEvents
' Set the comm port number.
MSComm1.CommPort = 3 'here is where you would have the port
assigned by the combo box but I have hard coded it.
' Read the entire buffer when Input is used.
MSComm1.InputLen = 0
' 9600 baud, no parity, 8 data bits, 1 stop bit.
MSComm1.Settings = "9600,N,8,1"
' Open the comm port.
MSComm1.PortOpen = True
' Send the attention string to the modem.
MSComm1.Output = "ATV1Q0" & Chr$(13)
' Wait for OK.
Do
' Read the latest data from the serial port.
DoEvents
results = results & MSComm1.Input
num_tries = num_tries + 1
If num_tries > MAX_TRIES Then
MsgBox "Did not get OK response in " & MAX_TRIES & "
tries"
Exit Do
End If
Loop Until InStr(results, "OK" & vbCrLf) > 0
' Dial the phone number.
MSComm1.Output = "ATDT " & CleanPhoneNumber(txtNumber.Text) &
vbCrlf
' Ask the user to wait until the phone rings.
MsgBox "When you hear a busy signal, click OK." & vbCrLf & _
"When you hear a ringing signal, pick up the receiver and
click
OK.", _
vbInformation Or vbOKOnly, "Please Wait"
' Close the serial port.
MSComm1.PortOpen = False
Screen.MousePointer = vbDefault
Exit Sub
Oops:
MsgBox "Error " & Err.Number & vbCrLf & _
Err.Description, _
vbExclamation Or vbOKOnly, _
"Error"
Screen.MousePointer = vbDefault
Exit Sub
End Sub
more on modems can be found here: http://www.azstarnet.com/service/modem/index.html.
I am not sure there is anything wrong with your old code except the
way in which you are trying to initialize the modem.
Sending: MSComm1.Output = "ATV1Q0" & Chr$(13) probably worked on the
older modem you were programming with before. What you will need to do
now is determine what kind of modem you are using and make a good
strig for it. The other method would be to implicate very complicated
routines that would check for all of the different types and then auto
determine the manufacturer and the required string.
I am sorry to tell you but this is not going to be an easy fix.
good luck.
.
- References:
- Proper Command Code for a simple Phone Dialer
- From: Verne H. Bohlender
- Proper Command Code for a simple Phone Dialer
- Prev by Date: Re: Threading in VB
- Next by Date: Re: msxml DOM: no linefeed after creating a new node
- Previous by thread: Proper Command Code for a simple Phone Dialer
- Next by thread: Re: Proper Command Code for a simple Phone Dialer
- Index(es):
Relevant Pages
|
Loading