Home Parallel Port Serial Port Serial Info Parallel Info USB .NET Webboard I/O Today API Project Directory

 Hardware Interfacing in VB programming.

Interfacing serial port with Visual Basic Part 2
Thai Page Click Here
In the section 1, I presented about the form of interface and programming to control MSComm 6 control of Visual Basic. In this section, I will present Comm Properties form that is the form of setting so that program can interface with com port, demonstrating by clicking setting button at the main form of the last section.


So, I will describe the texts showed at important coding, but function, condition, coding by Visual Basic. I won't mention.

 
1. Start by adding the new blank form by clicking at Project menu-->Add form.

2. Setting the qualification of the form, right click to choose Properties Dialog, then rename (1)Name to frmProperty, set BorderStyle(2) to 3 - Fixed dialog, put the name showed on the title bar in Caption(3) to Serial Port Properties , (4) set the button /status of form/scale size by changing to the picture showed below.

3. Then, drag control from ToolBox to form in the picture that I show the numbers Label(1) ,Frame (2) (3) (4) (5),Combo Box(6) (7) (8) (9) (10),Option(11) (12) (13) (14) (15) (16) , Command Button (17) (18).

4. Set the name in Properties -->Name,-->Font,-->Color and others. You can look at the name of control at title bar of Properties Dialog Box. The qualification of control that must be changed; I draw the red frame and show you the number of step of changing.

5. Programming to control procedures.

  • This code is procedure of Command Button, when click the button, MSComm will be set for interface with Com Port such as Buad Speed,Com Port, etc.

  • This code is the setting with controller, Additem, adding the name in the list of combo box, setting of MSComm.

  • This code will load and set controller for using in start working of program, allowing sub-program, named SettingPort. Also, procedure optEcho_click get the from Index in order to be set in optFlow_Click.

  • This is the form properties that have already run.

I think we ought to use Com Port, Com2, and then open the program we created to run together, after that, going to properties form as the picture above. the first program is chose as Com1, and the second program as Com2. Moreover, we must make the one connector line by using DB9 (female) with a transmission line in the following;

Caution: you must carefully connect the line. If you wrongly connect it, you might have the new one.

 

Data Reference : Visual Basic Programming Guide / http://www.vb-world.net / http://earthweb.com /


Copyright (c) 2000-2008 thaiio.com all rights reserved.  Contact webmaster :webmaster@thaiio.com