For this example to work, ensure that the following properties are set.
Property | Value |
RThreshold | 1 |
SThreshold | 1 |
InputLen | 0 |
ComPort | The location of your modem |
After this, firstly, we need to open the COM port. To do this, simply set the PortOpen property to true:
MSComm1.PortOpen = True
Then, we need to send the command. For this example, we will ask your modem to dial your own number. So, the command will be
ATDT01992245365
AT tells the modem that a command is coming up. DT tells it to dial the upcoming number using Tone dial. Then the text in red is the number to dial. Change the number in red to your own number. We also need to add a Chr$(13) after the command. You nearly always need to do this. So, to send this command, we enter
MSComm1.Output = "ATDT01992245365" &
Chr$(13)
You could of course, substitute the telephone number with a Text box, so that the user could enter the number:
MSComm1.Output = "ATDT" &
txtNumber.Text & Chr$(13)
Then, the modem will attempt to dial the number. If you want a list of the main commands to control a modem, click here. Of course, if the device connected to the COM port is not a modem, you will need to know what commands to send it.
At the moment, we have no way of knowing if the dialing was successful. This is where the OnComm event is useful. This is discussed in the next section.
Comments