VERSION 5.00 Begin VB.Form Form1 Caption = "USB-IIRO4-2SM" ClientHeight = 1695 ClientLeft = 5985 ClientTop = 6270 ClientWidth = 4725 LinkTopic = "Form1" ScaleHeight = 1695 ScaleWidth = 4725 Begin VB.Timer Timer1 Enabled = 0 'False Interval = 100 Left = 2160 Top = 1080 End Begin VB.Image inputImage Height = 375 Index = 3 Left = 2760 Top = 480 Width = 375 End Begin VB.Image inputImage Height = 375 Index = 2 Left = 3120 Top = 480 Width = 375 End Begin VB.Image inputImage Height = 375 Index = 1 Left = 3480 Top = 480 Width = 375 End Begin VB.Image inputImage Height = 375 Index = 0 Left = 3840 Top = 480 Width = 375 End Begin VB.Label Label2 Caption = "Inputs" Height = 255 Left = 3240 TabIndex = 1 Top = 120 Width = 615 End Begin VB.Image relayImage Height = 375 Index = 3 Left = 120 Top = 480 Width = 375 End Begin VB.Image relayImage Height = 375 Index = 2 Left = 480 Top = 480 Width = 375 End Begin VB.Image relayImage Height = 375 Index = 1 Left = 840 Top = 480 Width = 375 End Begin VB.Image relayImage Height = 375 Index = 0 Left = 1200 Top = 480 Width = 375 End Begin VB.Label Label1 Caption = "Relays" Height = 255 Left = 480 TabIndex = 0 Top = 120 Width = 615 End Begin VB.Image lowImage Height = 360 Left = 1560 Picture = "Form1.frx":0000 Top = 1080 Visible = 0 'False Width = 375 End Begin VB.Image highImage Height = 360 Left = 1080 Picture = "Form1.frx":06E2 Top = 1080 Visible = 0 'False Width = 375 End Begin VB.Image closedImage Height = 360 Left = 600 Picture = "Form1.frx":0DC4 Top = 1080 Visible = 0 'False Width = 360 End Begin VB.Image openImage Height = 360 Left = 120 Picture = "Form1.frx":1446 Top = 1080 Visible = 0 'False Width = 375 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Dim DeviceIndex As Long Dim update As Boolean Dim outData As Integer Private Sub Form_Load() Dim PID As Long Dim NameSize As Long Dim Name As String Dim DIOBytes As Long Dim Counters As Long Dim count As Integer Dim Status As Long DeviceIndex = diFirst Status = QueryDeviceInfo(DeviceIndex, PID, NameSize, Name, DIOBytes, Counters) If (Status <> 0) Or Not ((PID = &H8030&) Or (PID = &H8031&)) Then DetectForm.Show vbModal, Me If DetectForm.getIndex <> -1 Then DeviceIndex = DetectForm.getIndex() Else Unload Me Exit Sub End If End If For count = 0 To 3 relayImage(count).Picture = openImage.Picture inputImage(count).Picture = lowImage.Picture Next count outData = &HF DIO_WriteAll DeviceIndex, outData Timer1.Enabled = True End Sub Private Sub relayImage_Click(Index As Integer) Dim compare As Integer update = True compare = 2 ^ Index outData = outData Xor compare If (outData And compare) Then relayImage(Index).Picture = openImage.Picture Else relayImage(Index).Picture = closedImage.Picture End If End Sub Private Sub Timer1_Timer() Dim indata As Integer Dim count As Integer If update = True Then DIO_WriteAll DeviceIndex, outData update = False End If DIO_ReadAll DeviceIndex, indata indata = indata And &HF For count = 0 To 3 If indata And (2 ^ count) Then inputImage(count).Picture = highImage.Picture Else inputImage(count).Picture = lowImage.Picture End If Next count End Sub