Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

How to program RS232 (serial port) with Visual Basic?

Status
Not open for further replies.

azzintani

Newbie level 6
Joined
Jan 13, 2008
Messages
11
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,372
how to program RS232 (serial port) with visual basic.
 

antedeluvian

Full Member level 1
Joined
Apr 23, 2005
Messages
97
Helped
33
Reputation
66
Reaction score
17
Trophy points
1,288
Activity points
2,470
Re: V basic RS232

It depends on what version of VB you are using.

For VB.net I wrote an article on "Visual Basic 2005 and the Serial Port" in the December 2006 edition of Circuit Cellar.

http://www.circuitcellar.com/magazine/197toc.htm
Circuit Cellar charges a nominal amount for most articles.

For VB5/6/VBA there are several sources. The best is "Serial Port Complete" by Jan Axelson. The latest edition may also cover VB.net. There are several other books- just search for "serial port" on Amazon. Richard Grier is a name to follow as well,. The book I used is out of print, but there appears to be a more recent version.

Only the professional and enterprise editions of VB came with the serial port control. You can of course acquire and install the control yourself. See the discussion
https://www.edaboard.com/viewtopic.php?t=131095&highlight=serial

Forgive me if I take this opportunity to also tell you that there are two examples (chapters) that actually show you how to interface MS Excel to the serial port (plus one that uses the parallel port). The first describes an interface to a DVM and the second to a function generator.

The book is called "Excel by Example : A Microsoft Excel Cookbook for Electronics Engineers" ISBN 0750677562 (published by Elsevier) and is available in paperback or in electronic format. You can review the TOC and part of the first example at Amazon.com.

And there is always Google and Microsoft.

-Aubrey
 

Kuzito

Newbie level 6
Joined
Nov 5, 2006
Messages
14
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,283
Activity points
1,462
Re: V basic RS232

Hi,

I have this Visual Basic 6 code who send in HEX 'FF 01 00' and 'FF 01 01' to RS232. Hope this help you.

Code:
Private Sub cmdOff_Click() 
With MSComm1 
'make sure the serial port is open 
If .PortOpen = False Then .PortOpen = True 
'send the data 
.Output = Chr$(255) 
.Output = Chr$(1) 
.Output = Chr$(0) 
End With 'MSComm1 
End Sub 

Private Sub cmdOn_Click() 
With MSComm1 
'make sure the serial port is open 
If .PortOpen = False Then .PortOpen = True 
'send the data 
.Output = Chr$(255) 
.Output = Chr$(1) 
.Output = Chr$(1) 
End With 'MSComm1 
End Sub
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top