NETCommOCX Information Page

Return to Hard & Software | Download NETCommOCX (about 2.5 MB) | Updated installer for Windows 7 and Windows Vista (example code not included -- use other download to view examples). Right-click Setup and select "Run as Administrator"

What

The NETCommOCX is an ActiveX control that wraps the functionality of MSComm32.ocx.  You may use it if you do not need error-checked file transfers (use XMCommCRC for error-checked file transfers in addition to other conventional serial communication).

I wrote the NETComm ActiveX™ control using Microsoft® Visual Basic™ 6. It wraps the MSComm32.ocx that is furnished VB6 Professional and Enterprise Editions.  Unlike XMCommCRC.ocx, NETComm.ocx does not display an About MessageBox when instantiated.  Thus, it may be used with no limitations.

Why

I wanted to make MSComm features available to non-VB5/VB6 Professional or Enterprise edition users AND to make simple serial communications easy for users of Microsoft's new design environment Visual Studio .NET .  Visual Studio .NET does not include a control for serial communications.  It can use MSComm32.ocx using COM Interoperability.  However, MSComm32.ocx is not delivered with Visual Studio (nor is it licensed for use on systems that do not have VB5 or VB6 installed).  So, I have written this simple control for use in any environment that supports ActiveX controls.

Subsequent to the release of Visual Studio 2003, I coded a native VB .NET serial communications component that I call DesktopSerialIO.  It is compact, and it is easier to deploy than NETComm.ocx.  Therefore, I suggest that users employ it for new .NET applications.  Use this link to DesktopSerialIO.

See my book, Visual Basic Programmer's Guide to Serial Communications, 4thEdition,  published by Hard & Software (391 pages, includes CD-ROM). July 2004, Revised March 2006, for lots of working example code -- and .NET programming information.  Source code for DesktopSerialIO is included on the CD-ROM.

Details

(.NET) First, run the Setup program. This installs and registers the control and other required files. Then, from the .NET IDE, right-click on the Toolbox and select Add/Remove Items. From the Customize Toolbox dialog click on the COM Components tab. Click the Browse button and navigate to the folder where you installed NETComm.ocx. Select it from the Browse dialog, click Open, then click the OK button. This places the control in the Toolbox. Now, drop it on a Form (you must use it from the form. Visual Studio now builds a wrapper DLL, which takes a few seconds -- and it is ready to use.

Please refer to the VB5/6 documentation for the MSComm ActiveX control. I will not repeat that here (you can get a detailed description of MSComm properties and events from articles on www.msdn.microsoft.com; better yet, purchase a copy of my book). NETComm.ocx provides all essential properties, methods, and events provided by MSComm. There is one exception to this, due to an idiosyncrasy of ActiveX controls that are written in Visual Basic. I could not provide a control property named "Input", as is used in MSComm. Rather, I selected the property name "InputData". This property is used the same way as would be the MSComm Input property. For example,

Dim Buffer As String

Buffer = MSComm1.Input

Buffer = axNETComm1.InputData

.NET changes the naming convention rules for VB5/6 authored ActiveX control property Set statements.  Previous syntax to send data would have been something like NETComm1.Ouput = SomeData  However, the appropriate .NET syntax is:

axNETComm1.set_Output(SomeData)

OK, what about C#?  Good question.  I am not a C# expert, however there are some required syntax changes.  Here is a clip of a C# code fragment that illustrates sending data (who say's "VB isn't easier than C#?"  Notice the object and ref  casts that are needed.):

{

String Buffer = "1234";

String Settings = "9600, N, 8, 1";

Object oBuffer = (object)Buffer;

axNETComm1.set_Settings(ref Settings);

axNETComm1.PortOpen = true;

axNETComm1.set_Output(ref oBuffer);

}

One question that I often field is, "What speed does MSComm support?" The NETComm control, like MSComm32.ocx that comes with VB5 or later supports speeds up to 115200 bps. If you use either with a modem, make sure that you use a speed that is actually supported by the modem's serial port. These speeds are: 300, 1200, 2400, 9600, 19200, 38400, 57600, and 115200 bps. Do not attempt to use a speed like 28800 or 33600 bps. While the modem may connect at this speed, it CANNOT set its serial port to this speed. Instead, select a higher speed than the actual connect speed. 57600 or 115200 bps usually are best. Enable modem error correction and data compression, of course.

The Setup program for NETComm.ocx installs the OCX and registers it.  Also included are ZIP file with simple example source code using NETComm.ocx in VB6 and VB.NET.

NETComm OnComm Constants

NETCOMM_EV_SEND = 1
NETCOMM_EV_RECEIVE = 2
NETCOMM_EV_CTS = 3
NETCOMM_EV_DSR = 4
NETCOMM_EV_CD = 5
NETCOMM_EV_RING = 6
NETCOMM_EV_EOF = 7

NETCOMM_ER_BREAK = 1001
NETCOMM_ER_CTSTO = 1002
NETCOMM_ER_DSRTO = 1003
NETCOMM_ER_FRAME = 1004
NETCOMM_ER_OVERRUN = 1006
NETCOMM_ER_CDTO = 1007
NETCOMM_ER_RXOVER = 1008
NETCOMM_ER_RXPARITY = 1009
NETCOMM_ER_TXFULL = 1010

Note:  The NETComm.ocx Setup program uses InstallShield.  There is a file named Setup.pdf that is part of the InstallShield setup program.  This is not an Adobe Acrobat file, so don't be upset if you cannot view it.  I am sorry about the unfortunate naming convention used here, but I have no control over it.

License

Copyright (c) 2006, Richard L. Grier

Permission is hereby granted, free of charge, to any person or organization that downloads NETComm.ocx (the Software) to use the Software as described hereafter.  You are granted the right to use, copy, modify, or merge the Software.  The Software is explicitly copyrighted by Richard L. Grier. You may use it in any commercial or non-commercial application.  You may not publish, distribute, sublicense, and/or sell copies of the Software except in executable form.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHOR OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Feel free to contact me if you have problems. However, I cannot guarantee that I will be able to respond in a timely way. Please let me know about any successes.  Source code for NETComm.ocx is now included in the NETComm download.

Return to Hard & Software