Solved

Dial Phone from vb ap

Posted on 2001-06-06
8
788 Views
Last Modified: 2008-08-13
Hi All
In a vb 5 application, I have a list of phone numbers in a list box.  I would like to click on the number and have it dial that number through my modem.  What project references do I need?   What code do I need?
Thanks in advance.
0
Comment
Question by:fayb
  • 4
  • 3
8 Comments
 
LVL 2

Expert Comment

by:Microsoft
ID: 6161159
this is what you require

just click on the url below and download the zip file.

then open it with your vb editor

you can then take part of this code or add your code to it

good luck
http://www.freevbcode.com/ShowCode.ASP?SearchString=dial%20phone%20number&ID=1305

0
 
LVL 1

Expert Comment

by:svaik
ID: 6161163
Dial Phone Numbers Using MSComm Control: Demo
http://www.freevbcode.com/code/MSCommExample.zip
0
 

Author Comment

by:fayb
ID: 6161209
I get "retained is an invalid key and vb5 won't open the file"
0
 

Author Comment

by:fayb
ID: 6161217
Also if I click on just the form I get:
Line 43: Class MSCommLib.MSComm of control MSComm1 was not a loaded control class.
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 2

Expert Comment

by:Microsoft
ID: 6161344
Private Sub CancelButton_Click()    CancelFlag = True    CancelButton.Enabled = FalseEnd Sub

Private Sub Dial(Number$)    Dim DialString$, FromModem$, dummy    DialString$ = "ATDT" + Number$ + ";" + vbCr    MSComm1.CommPort = 2    MSComm1.Settings = "9600,N,8,1"    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    MSComm1.InBufferCount = 0    MSComm1.Output = DialString$

    Do        dummy = DoEvents()

        If MSComm1.InBufferCount Then            FromModem$ = FromModem$ + MSComm1.Input

            If InStr(FromModem$, "OK") Then                                Beep                MsgBox "Please pick up the phone and either press Enter or click OK"                Exit Do            End If        End If        'got help from microsoft


        If CancelFlag Then            CancelFlag = False            Exit Do        End If    Loop    MSComm1.Output = "ATH" + vbCr    MSComm1.PortOpen = FalseEnd Sub

Private Sub DialButton_Click()    Dim Number$, Temp$    DialButton.Enabled = False    QuitButton.Enabled = False    CancelButton.Enabled = True    Number$ = InputBox$("Enter phone number:", Number$)    If Number$ = "" Then Exit Sub    Temp$ = Status    Status = "Dialing - " + Number$    Dial Number$    DialButton.Enabled = True    QuitButton.Enabled = True    CancelButton.Enabled = False    Status = Temp$End Sub

Private Sub Form_Load()    MSComm1.InputLen = 0End Sub

Private Sub MSComm1_OnComm()End Sub

Private Sub QuitButton_Click()    EndEnd Sub
 

try that
0
 
LVL 2

Expert Comment

by:Microsoft
ID: 6161355
oops

i mean

Private Sub CancelButton_Click()  
CancelFlag = True
CancelButton.Enabled = False
End Sub

Private Sub Dial(Number$)
Dim DialString$, FromModem$, dummy
DialString$ = "ATDT" + Number$ + ";" + vbCr
MSComm1.CommPort = 2    
MSComm1.Settings = "9600,N,8,1"
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    MSComm1.InBufferCount = 0    MSComm1.Output = DialString$

 Do
 dummy = DoEvents()
 If MSComm1.InBufferCount Then
            FromModem$ = FromModem$ + MSComm1.Input
            If InStr(FromModem$, "OK") Then
            Beep                MsgBox "Please pick up the phone and either press Enter or click OK"  
    Exit Do
    End If      
  End If        


If CancelFlag Then
CancelFlag = False
Exit Do
End If
Loop
MSComm1.Output = "ATH" + vbCr  
MSComm1.PortOpen = False
End Sub

Private Sub DialButton_Click()
Dim Number$, Temp$  
DialButton.Enabled = False
QuitButton.Enabled = False
CancelButton.Enabled = True  
Number$ = InputBox$("Enter phone number:", Number$)
If Number$ = "" Then
Exit Sub  
 Temp$ = Status  
  Status = "Dialing - " + Number$
   Dial Number$
   DialButton.Enabled = True  
 QuitButton.Enabled = True
   CancelButton.Enabled = False  
  Status = Temp$End Sub

Private Sub Form_Load()  
 MSComm1.InputLen = 0
End Sub

Private Sub MSComm1_OnComm()
End Sub

Private Sub QuitButton_Click()    
End
End Sub
 

0
 
LVL 2

Accepted Solution

by:
Microsoft earned 100 total points
ID: 6161361
ARGHHH having trouble cutting and pasteing
sorry try this :-




Private Sub CancelButton_Click()  
CancelFlag = True
CancelButton.Enabled = False
End Sub

Private Sub Dial(Number$)
Dim DialString$, FromModem$, dummy
DialString$ = "ATDT" + Number$ + ";" + vbCr
MSComm1.CommPort = 2    
MSComm1.Settings = "9600,N,8,1"
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  
MSComm1.InBufferCount = 0
MSComm1.Output = DialString$

 Do
 dummy = DoEvents()
 If MSComm1.InBufferCount Then
            FromModem$ = FromModem$ + MSComm1.Input
            If InStr(FromModem$, "OK") Then
            Beep                MsgBox "Please pick up the phone and either press Enter or click OK"  
    Exit Do
    End If      
  End If        


If CancelFlag Then
CancelFlag = False
Exit Do
End If
Loop
MSComm1.Output = "ATH" + vbCr  
MSComm1.PortOpen = False
End Sub

Private Sub DialButton_Click()
Dim Number$, Temp$  
DialButton.Enabled = False
QuitButton.Enabled = False
CancelButton.Enabled = True  
Number$ = InputBox$("Enter phone number:", Number$)
If Number$ = "" Then
Exit Sub  
 Temp$ = Status  
  Status = "Dialing - " + Number$
   Dial Number$
   DialButton.Enabled = True  
 QuitButton.Enabled = True
   CancelButton.Enabled = False  
  Status = Temp$End Sub

Private Sub Form_Load()  
 MSComm1.InputLen = 0
End Sub

Private Sub MSComm1_OnComm()
End Sub

Private Sub QuitButton_Click()    
End
End Sub
 

0
 

Author Comment

by:fayb
ID: 6161477
OK, I put the script in a new VB5 form, created the elements, and after I fixed a couple of your cut/paste errors, and I added comm port 3 - It worked.  I think your original suggestion was for vb6.
Thanks.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

705 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now