Send a suggestion!

We're building a brand new version of the site, and we'd love to hear your ideas

Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

Rated
Read 156,511 times

Contents

Related Categories

Com Ports and the MSComm Control - Sending Data

Sending Data

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. 

James first started writing tutorials on Visual Basic in 1999 whilst starting this website (then known as VB Web). Since then, the site has grown rapidly, and James has written numerous tutorials, articles and reviews on VB, PHP, ASP and C#. In October 2003, James formed the company Developer Fusion Ltd, which owns this website, and also offers various development services. In his spare time, he's a 3rd year undergraduate studying Computer Science in the UK. He's also a Visual Basic MVP.

Comments

  • Re: [21] Com Ports and the MSComm Control

    Posted by raxe on 10 Jul 2006

    Hi. I need to comunicate with a money colector using VB 6.0 Pro. I had installed the MsComm control.


    How can i send this comands to the  money collector and how i can read the answers ...

  • Great Work!!!!

    Posted by zeezee on 09 Feb 2006

    First of all, I have to thank you for giving out this lovely tutorial:) This is a great help for folks like who has no idea in using the Ms comm Control, Thank you very much and keep up the good work....

  • Posted by vimal_up on 12 Dec 2005

    Dear Friend Virag,
    I have done lots of R&D in this matter, and what i found is, it is best option to go with third party controls & components to work with these type of apps. So search web u will ha...

  • how to boild IVR system usding VB

    Posted by viragonnet on 11 Dec 2005

    dear friend,

    i m looking for new tips for controling hardware using visual basic code.
    i also want to build interactive voice response system by which i can control my computer from anywhere. just...

  • IVR Application with MS Comm Control

    Posted by vimal_up on 15 Oct 2005

    Is it possible to develop simple IVR Apps with ms comm control in which step of wave file prompts guide the caller and he/she can choose option from phone buttons. By detecting caller choice programme...