Solved

VB5 Phone Dialer

Posted on 1997-05-02
3
185 Views
Last Modified: 2006-11-17
I have a screen which displays client information, including
the phone #. I want to dial this # when I press the dial label button. It should also give me relevant error messages. ( eg. line engaged, invalid # etc. ) Any source code and other information will be greatly apprecaited.
I am new to VB. Dilantha (-:
0
Comment
Question by:b3cf
  • 2
3 Comments
 
LVL 3

Accepted Solution

by:
ChrisLewis earned 100 total points
ID: 1425920
VB 5.0 Pro/Ent comes with a sample application that does exactly what you want.Put an MSCOMM on your form, then add a push button that calls the following function:+----------+----------+
+----------+----------+
Private Sub Dial(Number$)
    Dim DialString$, FromModem$, dummy

    ' AT is the Hayes compatible ATTENTION command and is required to send commands to the modem.
    ' DT means "Dial Tone." The Dial command uses touch tones, as opposed to pulse (DP = Dial Pulse).
    ' Numbers$ is the phone number being dialed.
    ' A semicolon tells the modem to return to command mode after dialing (important).
    ' A carriage return, vbCr, is required when sending commands to the modem.
    DialString$ = "ATDT" + Number$ + ";" + vbCr

    ' Communications port settings.
    ' Assuming that a mouse is attached to COM1, CommPort is set to 2
    MSComm1.CommPort = 2
    MSComm1.Settings = "9600,N,8,1"
   
    ' Open the communications port.
    On Error Resume Next
    MSComm1.PortOpen = True
    If Err Then
       MsgBox "COM2: not available. Change the CommPort property to another port."
       Exit Sub
    End If
   
    ' Flush the input buffer.
    MSComm1.InBufferCount = 0
   
    ' Dial the number.
    MSComm1.Output = DialString$
   
    ' Wait for "OK" to come back from the modem.
    Do
       dummy = DoEvents()
       ' If there is data in the buffer, then read it.
       If MSComm1.InBufferCount Then
          FromModem$ = FromModem$ + MSComm1.Input
          ' Check for "OK".
          If InStr(FromModem$, "OK") Then
             ' Notify the user to pick up the phone.
             Beep
             MsgBox "Please pick up the phone and either press Enter or click OK"
             Exit Do
          End If
       End If
       
       ' Did the user choose Cancel?
       If CancelFlag Then
          CancelFlag = False
          Exit Do
       End If
    Loop
   
    ' Disconnect the modem.
    MSComm1.Output = "ATH" + vbCr
   
    ' Close the port.
    MSComm1.PortOpen = False
End Sub

0
 

Author Comment

by:b3cf
ID: 1425921
Hi Chris,

Thanxx a lot for answering my question. I really
appreciate it.

Dilantha (-:

0
 

Author Comment

by:b3cf
ID: 1425922
Hi Chris,

Thanxx a lot for answering my question. I really
appreciate it.

Dilantha (-:

0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question