I/O ActiveX Control Instructions
 
 
 

I/O ActiveX Control in Visual Basic
1) Right click on the controls palette.
2) Select custom controls.
3) Check I/O control in list box.
4) Select OK.
5) Select the "I/O" control from the control palette and click on the Visual Basic form you are using.

Multiple Ports
 

I/O Functions in Visual Basic

Return values:
All functions return a 1 if successful and a 0 if un-successful. Except for ReadString() which returns the string read from the port.
 

Open(PortName, Setup)
Result = IO1.Open("LPT1:", "") 'Open a parallel Port.
Result = IO1.Open("COM2:", "baud=9600 parity=N data=8 stop=1") 'Open a serial Port.

Close() 'Closes an open port.
Result = IO1.Close()
 

WriteString(Data)
Result = IO1.WriteString("Hello World" + Chr(13) + Chr(10)) 'Sends "Hello World" to a printer or other device.

ReadString(Length)
String = IO1.ReadString(30) 'Reads data from a port. Typically a request for data precedes this command.
 

WriteByte(Data)
Result = IO1.WriteByte(Chr(10)) 'Sends Line feed to a printer or other device.

ReadByte(Length)
Result = IO1.ReadByte() 'Reads 1 data byte from a port. Typically a request for data precedes this command.
 

SetTimeOut(Time)
Result = IO1.SetTimeOut(20) 'Sets timeout factor, how long a request is tried before an error is returned.
 

SetHandshaking(HSMethod)
Result = IO1.SetHandshaking(2) 'Serial ports Only. 0 = None, 1 = Xon/Xoff, 2 = Hardware
 

Full Example:

Dim Result As Integer
Dim Str As String

Result = IO1.Open("LPT1:", "") 'Open a parallel Port.

Result = IO1.WriteString("Hello World" + Chr(13) + Chr(10))

Result = IO1.WriteString(Chr(5)) 'Request data
Str = IO1.ReadString(30) 'Read result

Result = IO1.Close() 'Close the port now that we are done
 
 
 

Note: Open can fail on NT4.0 if another device is setup to use the same port, that includes printer drivers. Remove any installed printer drivers from the port you are trying to Open if you are using NT.
 
 
 
 
 

Home Page | Site Map | Copyright (c) 1998 by JSPayne of Cortland NY