Dialing a modem from code
This example shows how to dial a number
through a modem or how to send data via a comm port. Open a new form and on the
toolbar click the more controls button (it's the one with the hammer on) and
scroll down and choose the Microsoft Communications Control (Version X). The
verison number is dependant on apps installed like Visual Basic and service
packs e.t.c. Please note the control used to ship with Internet Explorer as a
design time control it now only ships with developer programs.
Click and drag with the tool selected and you
will see a button type object appear with a phone on it. Double click it and set
the comm port that is valid for you. Most modems sit on com ports 2,3,4. Click
the OK button. Rename the object by viewing it's properties to something
meaningful to your application. For this example I'm going to name it ModemCom2.
Then in code use the following:-
|ModemCom2.PortOpen = True
ModemCom2.Output = "ATDT 01234567890" & vbCr
MsgBox "Have dialed, pickup receiver. Click ok when finished"
ModemCom2.PortOpen = False 'Hangs up
This piece of code dials the phone number
01234567890. Please note after closing the port using ModemCom2.PortOpen =
false, the call will be disconnected. If you want to handshake you will need to
check the buffer.
Dim ModemStr as String
If ModemCom2.InBufferCount Then
ModemStr + ModemCom2.Input
If InStr(ModemStr, "OK") Then
When it exits the do loop the phone number has been dialed. The
computer the other end needs to be a listener and will listen for a command you
send. If you have ever heard a fax machine you will know that it sends a
specific beep every few seconds while waiting for the receiving computer to pick