- Reading Serial Port Visual Basic
- Serial Port Visual Basic 6 Tutorial
- Serial Port Visual Basic 6.0
- Serial Port Visual Basic 6 7
Reading data using serial port Home. Programming Forum Software Development Forum. How we can access parallel port in visual basic 6.0; This is a visual basic 6.0 wav sound player class that plays any selected sound file in.wav format. It has the filename property to select the file and play property to play the sound file.
I'm not much experienced in VB6 serial port programming. I need to control another circuit through serial port. (I have heard that pin 4 and pin 7 are used for that purpose. If these pins are incorrect please tell me what pins are used for such purposes)
My requirement is to set those pins to high or low and read their levels(high or low) through VB6 program. How to do the task??
Reading Serial Port Visual Basic
Thanx,
mtrw3 Answers
Serial Port Visual Basic 6 Tutorial
There's good high-level advice in other answers, but from a practical POV it's pretty simple. There are two control inputs (DSR and CTS) and two control outputs (DTR and RTS). DTR is on pin 4 (9-pin version) and RTS is on pin 7. DSR / CTS are pins 6 and 8.
Place a Comm Port object on a VB form, and set .CommPort
to the number of your port. For pure logic control purposes it doesn't matter what .Settings
(baudrate etc) you use because you won't be sending and receiving any serial data, so just accept the defaults.
Set .PortOpen = True
, then change the DTR and RTS outputs by setting .DTREnable
/ .RTSEnable
to true or false as required. You should set these False at design time to avoid false triggering. Be aware that these lines may be toggled by the system when the PC reboots.
You can poll the .CTSHolding
and .DSRHolding
properties to detect changes on those inputs, or react to the .OnComm
event, which will get signaled when there's a change in either one. You still have to sort out which one caused the event, but that's just a Select Case.
You don't have to worry about the individual pins. Most operating systems expose system calls to manipulate the pins for you, and some languages (including VB6) provide ways to use those system calls. A quick Google search turned up a tutorial that includes some details on the pins, if you're interested. However, this one looks a little easier to follow, at least in my opinion.
Serial Port Visual Basic 6.0
mtrwmtrwRichard Grier's Visual Basic Programmer's Guide to Serial Communications is a good book that covers VB6 (and VB.Net): it's available from his website, about $40 US plus shipping.
It looks like he still hangs out on the VB6 newsgroup, so that's a good place to ask about serial programming.
MarkJ