Part-2 Serial RS-232 Communication @TarunShrivastava
Part-2 Serial RS-232 Communication  @TarunShrivastava
Uploaded September 2012 | Updated September 2026, 2 weeks ago
Visual Basic was designed to be easy to learn and use. The language not only allows programmers to easily create simple GUI applications, but also has the flexibility to develop fairly complex applications as well. Programming in VB is a combination of visually arranging components or controls on a form, specifying attributes and actions of those components, and writing additional lines of code for more functionality. Since default attributes and actions are defined for the components, a simple program can be created without the programmer having to write many lines of code. Performance problems were experienced by earlier versions, but with faster computers and native code compilation this has become less of an issue.

Although programs can be compiled into native code executables from version 5 onwards, they still require the presence of runtime libraries of approximately 2 MB in size. This runtime is included by default in Windows 2000 and later, but for earlier versions of Windows it must be distributed together with the executable.

Forms are created using drag and drop techniques. A tool is used to place controls (e.g., text boxes, buttons, etc.) on the form (window). Controls have attributes and event handlers associated with them. Default values are provided when the control is created, but may be changed by the programmer. Many attribute values can be modified during run time based on user actions or changes in the environment, providing a dynamic application. For example, code can be inserted into the form resize event handler to reposition a control so that it remains centered on the form, expands to fill up the form, etc. By inserting code into the event handler for a keypress in a text box, the program can automatically translate the case of the text being entered, or even prevent certain characters from being inserted.

Visual Basic can create executables (EXE files), ActiveX controls, DLL files, but is primarily used to develop Windows applications and to interface web database systems. Dialog boxes with less functionality (e.g., no maximize/minimize control) can be used to provide pop-up capabilities. Controls provide the basic functionality of the application, while programmers can insert additional logic within the appropriate event handlers. For example, a drop-down combination box will automatically display its list and allow the user to select any element. An event handler is called when an item is selected, which can then execute additional code created by the programmer to perform some action based on which element was selected, such as populating a related list.
Visual Basic can be used to access serial communication functions. Windows hides much of the complexity of serial communications and automatically puts any received characters in a receive buffer and characters sent into a transmission buffer. The receive buffer can be read by the program whenever it has time and the transmit buffer is emptied when it is free to send characters.

Communications control
Visual Basic allows many additional components to be added to the toolbox. The Microsoft Comm component is used to add a serial communication facility.
In order to use the Comms component the files MSCOMM16.OCX (for a 16-bit module) or MSCOMM32.OCX (for a 32-bit module) must be present in the WINDOWSSYSTEM directory. The class name is MSComm. The communications control provides the following two ways for handling communications:

Event-driven. Event-driven communications is the best method of handling serial communication as it frees the computer to do other things. The event can be defined as the reception of a character, a change in CD (carrier detect) or a change in RTS (request to send). The OnComm event can be used to capture these events. and also to detect communications errors.
Polling. CommEvent properties can be tested to determine if an event or an error has occurred. For example, the program can loop waiting for a character to be received. Once it is the character is read from the receive buffer. This method is normally used when the program has time to poll the communications receiver or that a known response is imminent.

where the strStr is a string which contains the RS-232 settings. This string takes the form:
"BBBB,P,D,S"
where
BBBBdefines the baud rate,
P the parity,
D the number of data bits, and
S the number of stop bits.
The following lists the valid baud rates (default is 9600Baud):
110, 300, 600, 1200, 2400, 9600, 14400, 19200, 38400, 56000, 128000, 256000.
The valid parity values are (default is N): E (Even), M (Mark), N (None), O (Odd), S (Space).
The valid data bit values are (default is 8): 4, 5, 6, 7 or 8.
The valid stop bit values are (default is 1). 1, 1.5 or 2.
An example of setting a control port to 4800Baud, even parity, 7 data bits and 1 stop bit is: Com1.Settings = "4800,E,7,1"
Part-2 Serial RS-232 CommunicationBorder security system CNN IBN News 2006Part-3 Keypad Interface for Alpha-numeric Numbers Display 2020TISHITU Hydrogen Home Gas HHO Stove with LPG, Risk Free with no Flash Back from Hydrogen Fuel Cell.HHO Pipe Flash Back ArrestorHHO hydrogen fuel cell welding high pressure flame741 Op-amp  LM35 temperature circuit DIYAC 220 Volts Shock Experience , Electric ShockSeven Segment Display & 7447 decoderTISHITU Part 1/3 of 8051 microcontrolled Digital LCD Clock Proteus SimulationFast Articles writing plagiarism free 2020Part-6 Keypad Interface for Alpha-numeric Numbers Display 2020
Tishitu |

Part-2 Serial RS-232 Communication

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER