Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
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!

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.0After 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/

![]() |
Keyboard Output With C
|
Need help PW in VB6
|

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