Solved

VB4 and Modems

Posted on 1997-04-23
5
239 Views
Last Modified: 2006-11-17
I have VB4 the standard edition.  Is it possible for me to send modem commands to the serial port from VB?  And if for some reason another program is using the port can I shut down that program and then restart it?
0
Comment
Question by:Xeno
5 Comments
 

Expert Comment

by:pdetagyos
ID: 1425618
Yes, it is possible.  And you can hang up the modem if another program is using it, but that may not be too friendly.  

Look up information on the RAS API.  There are also several third-party controls and libraries that allow you to simplify serial connections.
0
 
LVL 2

Expert Comment

by:weekee
ID: 1425619
Actually to do serial communication, there is a control known as communication control. It allow you to set com port baud rate and rrecive from modem or output to modem. THe ouput can be in terms oof AT commands too. The help file has the neccessary information and examples.
0
 
LVL 1

Expert Comment

by:advapp
ID: 1425620
You rejected both of the previous answers; could you explain what you are looking for?  Are you looking for sample code?
0
 

Author Comment

by:Xeno
ID: 1425621
Well let see... I had VB 4.0 the standard edition...and it appears not to support the MScomm stuff...I just now purchased VB5.0 upgrade and I am sorting through it... Hmmm.. a code sample would be great.
0
 
LVL 3

Accepted Solution

by:
ChrisLewis earned 100 total points
ID: 1425622
MSComm does not come with the standard version on VB, only the professional.  Don't know why...Some Code?  THis is from the Dialer project in VB 4.0/16bit samples: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).
    ' PhoneNumbers$(Index) is the phone number being dialed.
    ' A semicolon tells the modem to return to command mode after dialing (important).
    ' A carriage return, Chr$(13), is required when sending commands to the modem.
    DialString$ = "ATDT" + Number$ + ";" + Chr$(13)

    ' Communications port settings.
    Comm1.Settings = "300,N,8,1"
   
    ' Open the communications port.
    On Error Resume Next
    Comm1.PortOpen = True
    If Err Then
       MsgBox "COM1: not available. Change the CommPort property to another port."
       Exit Sub
    End If
   
    ' Flush the input buffer.
    Comm1.InBufferCount = 0
   
    ' Dial the number.
    Comm1.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 Comm1.InBufferCount Then
          FromModem$ = FromModem$ + Comm1.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.
    Comm1.Output = "ATH" + Chr$(13)
   
    ' Close the port.
    Comm1.PortOpen = False
End Sub
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

821 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