Computing.Net > Forums > Programming > Monitor a serial port for incoming data

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Monitor a serial port for incoming data

Reply to Message Icon

Name: Nurul Suhaida Abdul
Date: February 10, 2002 at 23:28:36 Pacific
Comment:

How to communicate with serial port (RS232) using Visual Basic 6.0 progamming
to send, retrive and receive data to/from it that captures ascii or binary data from
controller. I really need it to develop a database project. I hope you will give me the
programming and GUI using VB. Thank for help!



Sponsored Link
Ads by Google

Response Number 1
Name: Scouseknight
Date: February 11, 2002 at 02:26:45 Pacific
Reply:

Nurul,

This is achieved by using the MS Comm Control 6.0 component.

First thing is to make it available for selection :-

1) Project
2) Components
3) Check MS Comm Control 6.0

After doing this, you will see a telephone icon in your controls panel.

Open or create your form that will "listen" and then select the comms control, and draw it on your form (you may set this to Visible=False so it doesn't show on the final application).

The comms port will initialise with Baud Rate 9600, Parity None, Word Length 8, and Stop Bits 1 by default, which should be fine. If you need to change this, then right-click the control, and select Properties.

When the form is loaded, the comms control will initialise and wait until the form is closed.

To actually get it to listen, you need to use the onComm event.

Right click on the comms control, and select View Code.

Select the Comms control from the lefthand drop down, and the righthand selection will change to OnComm.

It will generate the sub for you, waiting for you to enter your responses to the events.

To monitor for data (assuming your control is named MSComm1) :-

Private Sub MSComm1_OnComm()
If MSComm1.CommEvent = comEvReceive Then
Dim Buffer As Variant
Buffer = MSComm1.Input
End If
End Sub


*Disclaimer - I do not have anything to connect to my comms port so I cannot test anything - the example is a general "in principle" way of doing it - all this is contained in the MSDN documentation, and countless examples are available on the net - do a search in Google.

I found this excellent resource :

http://www.vbweb.co.uk/vb/71/2/


0

Response Number 2
Name: hameedreza tavakoli
Date: May 7, 2002 at 23:43:55 Pacific
Reply:

hello.
tell me how can I Monitor a serial port for incoming data IN VB6.0 using Interrupts .
thanks.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Keyboard Output With C Need help PW in VB6



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Monitor a serial port for incoming data

Monitor a serial port for incoming data www.computing.net/answers/programming/monitor-a-serial-port-for-incoming-data/741.html

Batch files and serial ports? www.computing.net/answers/programming/batch-files-and-serial-ports/16989.html

ASCII Commands for Serial port www.computing.net/answers/programming/ascii-commands-for-serial-port/7499.html