VERSION 5.00 Begin VB.Form IDIOForm BorderStyle = 3 'Fixed Dialog Caption = "Isolated Input/Digital Output Test/Sample" ClientHeight = 3840 ClientLeft = 6600 ClientTop = 5940 ClientWidth = 6150 LinkTopic = "Form1" MaxButton = 0 'False MinButton = 0 'False ScaleHeight = 3840 ScaleWidth = 6150 ShowInTaskbar = 0 'False Begin VB.TextBox IsaEdit Height = 285 Left = 3480 TabIndex = 10 Text = "300" Top = 600 Width = 855 End Begin VB.Timer Timer1 Enabled = 0 'False Interval = 1000 Left = 2640 Top = 3360 End Begin VB.Frame Frame1 Caption = "Status" Height = 1695 Left = 120 TabIndex = 7 Top = 1560 Width = 5895 Begin VB.TextBox Memo1 Height = 1335 Left = 120 Locked = -1 'True MultiLine = -1 'True ScrollBars = 2 'Vertical TabIndex = 8 Top = 240 Width = 5655 End End Begin VB.CommandButton ExitButton Caption = "E&xit" Height = 375 Left = 4320 TabIndex = 6 Top = 3360 Width = 1575 End Begin VB.CommandButton PerformButton Caption = "Perform I/O" Height = 375 Left = 240 TabIndex = 1 Top = 3360 Width = 1455 End Begin VB.Label IsaLabel AutoSize = -1 'True Caption = "Base Address for 104-IDIO-16 card (in hex):" Height = 195 Left = 240 TabIndex = 9 Top = 600 Width = 3075 End Begin VB.Label OptoIn Alignment = 2 'Center BorderStyle = 1 'Fixed Single Caption = "0000000000000000" Height = 255 Left = 3480 TabIndex = 5 Top = 1200 Width = 2175 End Begin VB.Label RelayOut Alignment = 2 'Center BorderStyle = 1 'Fixed Single Caption = "0000000000000000" Height = 255 Left = 480 TabIndex = 4 Top = 1200 Width = 2175 End Begin VB.Label Label5 AutoSize = -1 'True Caption = "Opto Input" Height = 195 Left = 4200 TabIndex = 3 Top = 960 Width = 750 End Begin VB.Label Label3 AutoSize = -1 'True Caption = "Relay Output" Height = 195 Left = 960 TabIndex = 2 Top = 960 Width = 930 End Begin VB.Label Label1 AutoSize = -1 'True Caption = "Windows 104-IDIO-16 Sample" BeginProperty Font Name = "MS Sans Serif" Size = 13.5 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 360 Left = 960 TabIndex = 0 Top = 120 Width = 4155 End End Attribute VB_Name = "IDIOForm" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Declare Function InPortB Lib "ACCES32.dll" Alias "VBInPortB" (ByVal Port As Long) As Integer Private Declare Function OutPortB Lib "ACCES32.dll" Alias "VBOutPortB" (ByVal Port As Long, ByVal Value As Byte) As Integer Private Declare Function GetTickCount Lib "Kernel32.dll" () As Long Dim Ports(4) As Long Public RunFlag As Boolean Public Address As Long Public MyIndex As Integer Dim MyValues(3) As Integer Public Msg As String Private Sub AddressLabel_Click() End Sub Private Sub ExitButton_Click() End End Sub Private Sub Form_Load() Memo1.Text = "This sample program will sequentially turn on all bits of the relay input and sequentially turn them off. Each time it sets a new bit, both the relay output and the relay input are read and the data is displayed. This demonstrates how to read and write to the relays and how to use the readback function of the board." + Chr(13) + Chr(10) Memo1.SelStart = 32768 If (InPortB(&H61) = &HAA55) Then Call MsgBox("ACCESNT.SYS not detected. Please copy ACCESNT.SYS into [NT]/system32/drivers and re-run this sample.", 0, "Warning") End If End Sub Private Sub PerformButton_Click() If Not RunFlag Then Address = "&H" + IsaEdit.Text End If If Timer1.Enabled Then Timer1.Enabled = False: PerformButton.Caption = "Perform I/O" Else Timer1.Enabled = True: PerformButton.Caption = "Stop I/O" End If End Sub Private Sub Timer1_Timer() If (MyIndex < 8) Then MyValues(1) = 0 MyValues(0) = 2 ^ MyIndex Else MyValues(0) = 0 MyValues(1) = 2 ^ (MyIndex Mod 8) End If If (MyIndex < 8) Then Call OutPortB(Address, MyValues(0)) Else Call OutPortB(Address + 4, MyValues(1)) End If y = GetTickCount + 10 While (GetTickCount < y) Wend If (MyIndex < 8) Then MyValues(3) = 0 MyValues(2) = InPortB(Address + 1) Else MyValues(2) = 0 MyValues(3) = InPortB(Address + 5) End If MyIndex = MyIndex + 1 MyIndex = MyIndex Mod 16 Msg = "" For j = 7 To 0 Step -1 If (MyValues(1) And (2 ^ j)) Then Msg = Msg & "1" Else Msg = Msg & "0" End If Next For j = 7 To 0 Step -1 If (MyValues(0) And (2 ^ j)) Then Msg = Msg & "1" Else Msg = Msg & "0" End If Next RelayOut.Caption = Msg Msg = "" For j = 7 To 0 Step -1 If (MyValues(3) And (2 ^ j)) Then Msg = Msg & "1" Else Msg = Msg & "0" End If Next For j = 7 To 0 Step -1 If (MyValues(2) And (2 ^ j)) Then Msg = Msg & "1" Else Msg = Msg & "0" End If Next OptoIn.Caption = Msg End Sub