SAMPLE: Program Example for COM Port Support in Visual Basic

ID: Q140880


The information in this article applies to:
  • Microsoft Visual Basic Professional and Enterprise Editions, 16-bit only, for Windows, version 4.0


SUMMARY

A sample program (VBCOMDEM) is available to show you how a Visual Basic program can use Windows API functions for serial port communications. This program may not be necessary in Visual Basic versions 2.0, 3.0 and 4.0 for Windows because COM support is already built into the Communications Control, which comes with the Professional Edition.

The following file is available for download from the Microsoft Download Center. Click the file name below to download the file:

Vbcomdem.exe
For more information about how to download files from the Microsoft Download Center, please visit the Download Center at the following Web address
http://www.microsoft.com/downloads/search.asp
and then click How to use the Microsoft Download Center.

When you run Vbcomdem.exe, you will have the following four files:
Simpcomm.exe, Simpcomm.frm, Simpcomm.glb, Simpcomm.mak


MORE INFORMATION

In the Visual Basic environment (VB.EXE), you can load the files in this sample program by choosing Open Project from the File menu and selecting the Simpcomm.mak file.

You can also run Simpcomm.exe in Windows as a separate program that requires the Visual Basic run-time file Vbrun100.dll.

This sample program is only a starting point. It does not use all of the serial communications API functions available through Windows. This simple example uses Windows API Comm functions, such as OpenComm, CloseComm, ReadComm, and WriteComm. You are free to modify and extend the program to suit your specific needs.

The SIMPCOMM program has no error trapping, and makes no allowances for noisy communication lines or handshaking errors. Should an error occur, Windows will suspend all reading from the communications port until you clear the error by calling the Windows API function GetCommError.


To modify or understand this program example, you must have a reference manual for the Windows API routines.


REFERENCES

"Microsoft Windows Programmer's Reference," Microsoft Press, 1990 Microsoft Windows 3.0 Software Development Kit

Additional query words: 1.00 2.00 3.00 4.00 COM1 COM2 asynchronous softlib

Keywords : kbsample kb16bitonly kbVBp400 PrgCtrlsStd VB4WIN
Version : WINDOWS:4.0
Platform : WINDOWS
Issue type :


Last Reviewed: December 10, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.