VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 5580 ClientLeft = 60 ClientTop = 450 ClientWidth = 8385 LinkTopic = "Form1" ScaleHeight = 5580 ScaleWidth = 8385 StartUpPosition = 3 'Windows Default Begin VB.TextBox AddrText Height = 375 Left = 3960 TabIndex = 9 Text = "300" Top = 1080 Width = 975 End Begin VB.Timer Timer1 Enabled = 0 'False Interval = 1000 Left = 360 Top = 4920 End Begin VB.TextBox Instructions Height = 1935 Left = 960 MultiLine = -1 'True TabIndex = 8 Text = "Form1.frx":0000 Top = 2640 Width = 6495 End Begin VB.CommandButton StopBtn Caption = "Stop Input" Height = 375 Left = 1440 TabIndex = 6 Top = 4680 Width = 2055 End Begin VB.CommandButton Exit Caption = "Exit" Height = 375 Left = 4800 TabIndex = 5 Top = 4680 Width = 2055 End Begin VB.CommandButton StartButton Caption = "Start Input" Height = 375 Left = 1440 TabIndex = 4 Top = 4680 Width = 2055 End Begin VB.TextBox InText Alignment = 2 'Center Height = 285 Left = 3480 TabIndex = 3 Top = 2040 Width = 3735 End Begin VB.TextBox OutText Alignment = 2 'Center Height = 285 Left = 960 TabIndex = 2 Top = 2040 Width = 1815 End Begin VB.Label Label3 Caption = "Enter Base Address" Height = 255 Left = 2400 TabIndex = 10 Top = 1080 Width = 1455 End Begin VB.Label Label2 Alignment = 2 'Center Caption = "104-II32-4RO Windows Sample" BeginProperty Font Name = "MS Sans Serif" Size = 24 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 675 Left = 720 TabIndex = 7 Top = 240 Width = 6825 End Begin VB.Label Label1 Caption = "Output" Height = 255 Left = 1440 TabIndex = 1 Top = 1680 Width = 1095 End Begin VB.Label Input Caption = "Input" Height = 255 Left = 4920 TabIndex = 0 Top = 1680 Width = 855 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 done As Boolean Dim outByte As Byte Dim address As Long Private Sub Exit_Click() Unload Me End Sub Private Sub Form_Load() StopBtn.Visible = False setDirections End Sub Private Sub StartButton_Click() outByte = 0 done = False address = "&h" + AddrText StartButton.Visible = False StopBtn.Visible = True Timer1.Enabled = True End Sub Private Sub StopBtn_Click() StartButton.Visible = True StopBtn.Visible = False done = True Timer1.Enabled = False End Sub Private Sub setDirections() Instructions.Text = "This sample program will sequentially walk a bit through all the relays. Each time it sets a new bit, the inputs are read and the data is displayed. This demonstrates how to write to the relays and how to use the inputs on the board." End Sub Private Sub Timer1_Timer() Dim inBytes(3) As Byte Dim i As Integer Dim j As Integer For i = 1 To 3 inBytes(i) = InPortB(address) Next i OutPortB address, outByte OutText = "" InText = "" For j = 3 To 0 Step -1 For i = 7 To 0 Step -1 If ShiftRight(inBytes(j), i) Mod 2 = 1 Then InText = InText + "1" Else InText = InText + "0" End If Next i Next j For i = 3 To 0 Step -1 If ShiftRight(outByte, i) Mod 2 = 1 Then OutText = OutText + "1" Else OutText = OutText + "0" End If Next i Select Case outByte Case 0 outByte = 1 Case 8 outByte = 0 Case Else outByte = ShiftLeft(outByte, 1) End Select End Sub