Listing 1 'I/O test program 'David A. Ward June 2001 'For use with the 32 address 8 bit I/O card 'inpout32.dll must be in the Windows\Systems directory 'for the INP and OUT commands to work. 'the following code must also be located in a separate module: 'Public Declare Function Inp Lib "inpout32.dll" Alias "Inp32" (ByVal PortAddress As Integer) As Integer 'Public Declare Sub Out Lib "inpout32.dll" Alias "Out32" (ByVal PortAddress As Integer, ByVal Value) Option Explicit Dim X, Y, T, Z, PortAddress_in, PortAddress_out, Number, Total As Integer 'Flashing LED show Private Sub cmdShow_Click() MousePointer = 13 'change cursor to indicate the program is busy 'shift LED's from LSB up through MSB Z = 0 While Z < 10 X = 0 While X < 8 Out PortAddress_out, 255 - 2 ^ X Call Delay X = X + 1 Wend 'Shift LED's from MSB down through LSB X = 7 While X > -1 Out PortAddress_out, 255 - 2 ^ X Call Delay X = X - 1 Wend Z = Z + 1 Wend 'turn every other LED off and on Z = 0 While Z < 10 Out PortAddress_out, 0 Out PortAddress_out, 170 Call Delay Out PortAddress_out, 85 Call Delay Z = Z + 1 Wend 'turn all LED's off Out PortAddress_out, 255 MousePointer = 0 End Sub 'Delay subroutine Private Sub Delay() Dim PauseTime, Start PauseTime = 0.01 ' Set duration at 10mS. Start = Timer ' Set start time. Do While Timer < Start + PauseTime DoEvents ' Yield to other processes. Loop End Sub 'Write check box data to the output port 'change checked box circles from black to red or red to black if unchecked Private Sub cmdWriteToPort_Click() If Check1(0).Value = vbChecked Then Number = 1: Shape1(0).FillColor = &HFF& _ Else Shape1(0).FillColor = &H0& If Check1(1).Value = vbChecked Then Number = Number + 2: Shape1(1).FillColor = &HFF& _ Else Shape1(1).FillColor = &H0& If Check1(2).Value = vbChecked Then Number = Number + 4: Shape1(2).FillColor = &HFF& _ Else Shape1(2).FillColor = &H0& If Check1(3).Value = vbChecked Then Number = Number + 8: Shape1(3).FillColor = &HFF& _ Else Shape1(3).FillColor = &H0& If Check1(4).Value = vbChecked Then Number = Number + 16: Shape1(4).FillColor = &HFF& _ Else Shape1(4).FillColor = &H0& If Check1(5).Value = vbChecked Then Number = Number + 32: Shape1(5).FillColor = &HFF& _ Else Shape1(5).FillColor = &H0& If Check1(6).Value = vbChecked Then Number = Number + 64: Shape1(6).FillColor = &HFF& _ Else Shape1(6).FillColor = &H0& If Check1(7).Value = vbChecked Then Number = Number + 128: Shape1(7).FillColor = &HFF& _ Else Shape1(7).FillColor = &H0& Out PortAddress_out, 255 - Number Text1.Text = Number Number = 0 End Sub 'Read binary data from the input port Private Sub CmdRead_Click() Total = Inp(PortAddress_in) Text2.Text = Total If Total And 1 Then Text3(0).Text = "1" _ Else: Text3(0) = "0" If Total And 2 Then Text3(1).Text = "1" _ Else: Text3(1) = "0" If Total And 4 Then Text3(2).Text = "1" _ Else: Text3(2) = "0" If Total And 8 Then Text3(3).Text = "1" _ Else: Text3(3) = "0" If Total And 16 Then Text3(4).Text = "1" _ Else: Text3(4) = "0" If Total And 32 Then Text3(5).Text = "1" _ Else: Text3(5) = "0" If Total And 64 Then Text3(6).Text = "1" _ Else: Text3(6) = "0" If Total And 128 Then Text3(7).Text = "1" _ Else: Text3(7) = "0" End Sub 'Clear out bits on form and set all port bits to 0 Private Sub CmdClear_Click() For X = 0 To 7 Check1(X).Value = False Shape1(X).FillColor = &H0& Text3(X) = "" Next X Number = 0 Out PortAddress_out, 255 - Number Text1.Text = "" Text2.Text = "" End Sub Private Sub Port_in_Click() PortAddress_in = Port_in.Text End Sub Private Sub Port_out_Click() PortAddress_out = Port_out.Text End Sub Private Sub Form_Load() 'set up port addresses PortAddress_in = Port_in.Text PortAddress_out = Port_out.Text End Sub