Solved

VB4 and Modems

Posted on 1997-04-23
5
223 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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…
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

758 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

20 Experts available now in Live!

Get 1:1 Help Now