Re: Proper Command Code for a simple Phone Dialer



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.
.



Relevant Pages

  • Re: Why are 56K Modems Limited to 44.4K
    ... >> And you will Never achieve 56K on any Modem. ... >> Phone line to your Server and the Server dose the opposite.....this all ... >> you need to Break down your String the Default string is all well and ... >> but it has Data compression on and Flow Error controls on which you do ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: Why are 56K Modems Limited to 44.4K
    ... > Modem but using the F1 or F&1 string by default is the best in my Opinion ... > Ok lets say your connection from your server is Rated at 33.3Kb/s you will ... > but it has Data compression on and Flow Error controls on which you do not ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: AS5300 in POS environment
    ... The CONNECT string is sent by a modem to its local DTE. ... You can cause MICA not to send a CONNECT string when answering calls ...
    (comp.dcom.sys.cisco)
  • Re: [SLE] (SOLVED!!!)(Revisited) Works in Windoze, NOT in SuSE!?!?!?!?!?!?
    ... dns wasn't working after fresh system install with default modem ... When I changed the init string it began working. ... I'm almost afraid of my modem now. ... Ok, install bind. ...
    (SuSE)
  • Re: Any Idea to implement communication via RS232 port in VB6
    ... Public Function OpenCommPort(Optional CommPort As Integer = 0, ... MsgBox "You must select a comm port and configure it's settings first. ... OpenCommPort = Err.Description ... Private Sub ExampleSendString(PassedString as string) ...
    (microsoft.public.vb.general.discussion)

Loading