VERSION 5.00 Begin VB.Form DIO BorderStyle = 1 'Fixed Single Caption = "PCI2312_DIO" ClientHeight = 6240 ClientLeft = 45 ClientTop = 435 ClientWidth = 11805 LinkTopic = "Form1" MaxButton = 0 'False MinButton = 0 'False ScaleHeight = 6240 ScaleWidth = 11805 StartUpPosition = 3 '窗口缺省 Begin VB.CommandButton Command_ReadDI Caption = "读取DI" Height = 375 Left = 5400 TabIndex = 18 Top = 5280 Width = 1335 End Begin VB.CommandButton Command_DI Caption = "开关7" Enabled = 0 'False Height = 375 Index = 7 Left = 6960 Style = 1 'Graphical TabIndex = 17 Top = 4320 Width = 1095 End Begin VB.CommandButton Command_DI Caption = "开关6" Enabled = 0 'False Height = 375 Index = 6 Left = 6960 Style = 1 'Graphical TabIndex = 16 Top = 3840 Width = 1095 End Begin VB.CommandButton Command_DI Caption = "开关5" Enabled = 0 'False Height = 375 Index = 5 Left = 6960 Style = 1 'Graphical TabIndex = 15 Top = 3360 Width = 1095 End Begin VB.CommandButton Command_DI Caption = "开关4" Enabled = 0 'False Height = 375 Index = 4 Left = 6960 Style = 1 'Graphical TabIndex = 14 Top = 2880 Width = 1095 End Begin VB.CommandButton Command_DI Caption = "开关3" Enabled = 0 'False Height = 375 Index = 3 Left = 6960 Style = 1 'Graphical TabIndex = 13 Top = 2400 Width = 1095 End Begin VB.CommandButton Command_DI Caption = "开关2" Enabled = 0 'False Height = 375 Index = 2 Left = 6960 Style = 1 'Graphical TabIndex = 12 Top = 1920 Width = 1095 End Begin VB.CommandButton Command_DI Caption = "开关1" Enabled = 0 'False Height = 375 Index = 1 Left = 6960 Style = 1 'Graphical TabIndex = 11 Top = 1440 Width = 1095 End Begin VB.Frame Frame2 Caption = "开关量输入状态" Height = 4335 Left = 6480 TabIndex = 9 Top = 600 Width = 4455 Begin VB.CommandButton Command_DI Caption = "开关8" Enabled = 0 'False Height = 375 Index = 8 Left = 2520 Style = 1 'Graphical TabIndex = 34 Top = 360 Width = 1095 End Begin VB.CommandButton Command_DI Caption = "开关9" Enabled = 0 'False Height = 375 Index = 9 Left = 2520 Style = 1 'Graphical TabIndex = 33 Top = 840 Width = 1095 End Begin VB.CommandButton Command_DI Caption = "开关10" Enabled = 0 'False Height = 375 Index = 10 Left = 2520 Style = 1 'Graphical TabIndex = 32 Top = 1320 Width = 1095 End Begin VB.CommandButton Command_DI Caption = "开关11" Enabled = 0 'False Height = 375 Index = 11 Left = 2520 Style = 1 'Graphical TabIndex = 31 Top = 1800 Width = 1095 End Begin VB.CommandButton Command_DI Caption = "开关12" Enabled = 0 'False Height = 375 Index = 12 Left = 2520 Style = 1 'Graphical TabIndex = 30 Top = 2280 Width = 1095 End Begin VB.CommandButton Command_DI Caption = "开关13" Enabled = 0 'False Height = 375 Index = 13 Left = 2520 Style = 1 'Graphical TabIndex = 29 Top = 2760 Width = 1095 End Begin VB.CommandButton Command_DI Caption = "开关14" Enabled = 0 'False Height = 375 Index = 14 Left = 2520 Style = 1 'Graphical TabIndex = 28 Top = 3240 Width = 1095 End Begin VB.CommandButton Command_DI Caption = "开关15" Enabled = 0 'False Height = 375 Index = 15 Left = 2520 Style = 1 'Graphical TabIndex = 27 Top = 3720 Width = 1095 End Begin VB.CommandButton Command_DI Caption = "开关0" Enabled = 0 'False Height = 375 Index = 0 Left = 480 Style = 1 'Graphical TabIndex = 10 Top = 360 Width = 1095 End End Begin VB.Frame Frame1 Caption = "开关量输出控制" Height = 4335 Left = 840 TabIndex = 0 Top = 600 Width = 4215 Begin VB.CommandButton Command_DO Caption = "开关8[关]" Height = 375 Index = 8 Left = 2400 Style = 1 'Graphical TabIndex = 26 Top = 360 Width = 1095 End Begin VB.CommandButton Command_DO Caption = "开关9[关]" Height = 375 Index = 9 Left = 2400 Style = 1 'Graphical TabIndex = 25 Top = 840 Width = 1095 End Begin VB.CommandButton Command_DO Caption = "开关10[关]" Height = 375 Index = 10 Left = 2400 Style = 1 'Graphical TabIndex = 24 Top = 1320 Width = 1095 End Begin VB.CommandButton Command_DO Caption = "开关11[关]" Height = 375 Index = 11 Left = 2400 Style = 1 'Graphical TabIndex = 23 Top = 1800 Width = 1095 End Begin VB.CommandButton Command_DO Caption = "开关12[关]" Height = 375 Index = 12 Left = 2400 Style = 1 'Graphical TabIndex = 22 Top = 2280 Width = 1095 End Begin VB.CommandButton Command_DO Caption = "开关13[关]" Height = 375 Index = 13 Left = 2400 Style = 1 'Graphical TabIndex = 21 Top = 2760 Width = 1095 End Begin VB.CommandButton Command_DO Caption = "开关14[关]" Height = 375 Index = 14 Left = 2400 Style = 1 'Graphical TabIndex = 20 Top = 3240 Width = 1095 End Begin VB.CommandButton Command_DO Caption = "开关15[关]" Height = 375 Index = 15 Left = 2400 Style = 1 'Graphical TabIndex = 19 Top = 3720 Width = 1095 End Begin VB.CommandButton Command_DO Caption = "开关7[关]" Height = 375 Index = 7 Left = 360 Style = 1 'Graphical TabIndex = 8 Top = 3720 Width = 1095 End Begin VB.CommandButton Command_DO Caption = "开关6[关]" Height = 375 Index = 6 Left = 360 Style = 1 'Graphical TabIndex = 7 Top = 3240 Width = 1095 End Begin VB.CommandButton Command_DO Caption = "开关5[关]" Height = 375 Index = 5 Left = 360 Style = 1 'Graphical TabIndex = 6 Top = 2760 Width = 1095 End Begin VB.CommandButton Command_DO Caption = "开关4[关]" Height = 375 Index = 4 Left = 360 Style = 1 'Graphical TabIndex = 5 Top = 2280 Width = 1095 End Begin VB.CommandButton Command_DO Caption = "开关3[关]" Height = 375 Index = 3 Left = 360 Style = 1 'Graphical TabIndex = 4 Top = 1800 Width = 1095 End Begin VB.CommandButton Command_DO Caption = "开关2[关]" Height = 375 Index = 2 Left = 360 Style = 1 'Graphical TabIndex = 3 Top = 1320 Width = 1095 End Begin VB.CommandButton Command_DO Caption = "开关1[关]" Height = 375 Index = 1 Left = 360 Style = 1 'Graphical TabIndex = 2 Top = 840 Width = 1095 End Begin VB.CommandButton Command_DO Caption = "开关0[关]" Height = 375 Index = 0 Left = 360 Style = 1 'Graphical TabIndex = 1 Top = 360 Width = 1095 End End End Attribute VB_Name = "DIO" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Dim bDISts(0 To 15) As Byte Dim bDOSts(0 To 15) As Byte Dim hDevice As Long Dim DeviceLgcID As Integer Private Sub Command_DO_Click(Index As Integer) Select Case Index Case 0: If bDOSts(0) = 1 Then Me.Command_DO(Index).BackColor = RGB(192, 192, 192) Me.Command_DO(Index).Caption = "开关" + CStr(Index) + "[关]" bDOSts(0) = 0 Else Me.Command_DO(Index).Caption = "开关" + CStr(Index) + "[开]" Me.Command_DO(Index).BackColor = RGB(0, 255, 255) bDOSts(0) = 1 End If Case 1: If bDOSts(1) = 1 Then Me.Command_DO(Index).BackColor = RGB(192, 192, 192) Me.Command_DO(Index).Caption = "开关" + CStr(Index) + "[关]" bDOSts(1) = 0 Else Me.Command_DO(Index).Caption = "开关" + CStr(Index) + "[开]" Me.Command_DO(Index).BackColor = RGB(0, 255, 255) bDOSts(1) = 1 End If Case 2: If bDOSts(2) = 1 Then Me.Command_DO(Index).BackColor = RGB(192, 192, 192) Me.Command_DO(Index).Caption = "开关" + CStr(Index) + "[关]" bDOSts(2) = 0 Else Me.Command_DO(Index).Caption = "开关" + CStr(Index) + "[开]" Me.Command_DO(Index).BackColor = RGB(0, 255, 255) bDOSts(2) = 1 End If Case 3: If bDOSts(3) = 1 Then Me.Command_DO(Index).BackColor = RGB(192, 192, 192) Me.Command_DO(Index).Caption = "开关" + CStr(Index) + "[关]" bDOSts(3) = 0 Else Me.Command_DO(Index).Caption = "开关" + CStr(Index) + "[开]" Me.Command_DO(Index).BackColor = RGB(0, 255, 255) bDOSts(3) = 1 End If Case 4: If bDOSts(4) = 1 Then Me.Command_DO(Index).BackColor = RGB(192, 192, 192) Me.Command_DO(Index).Caption = "开关" + CStr(Index) + "[关]" bDOSts(4) = 0 Else Me.Command_DO(Index).Caption = "开关" + CStr(Index) + "[开]" Me.Command_DO(Index).BackColor = RGB(0, 255, 255) bDOSts(4) = 1 End If Case 5: If bDOSts(5) = 1 Then Me.Command_DO(Index).BackColor = RGB(192, 192, 192) Me.Command_DO(Index).Caption = "开关" + CStr(Index) + "[关]" bDOSts(5) = 0 Else Me.Command_DO(Index).Caption = "开关" + CStr(Index) + "[开]" Me.Command_DO(Index).BackColor = RGB(0, 255, 255) bDOSts(5) = 1 End If Case 6: If bDOSts(6) = 1 Then Me.Command_DO(Index).BackColor = RGB(192, 192, 192) Me.Command_DO(Index).Caption = "开关" + CStr(Index) + "[关]" bDOSts(6) = 0 Else Me.Command_DO(Index).Caption = "开关" + CStr(Index) + "[开]" Me.Command_DO(Index).BackColor = RGB(0, 255, 255) bDOSts(6) = 1 End If Case 7: If bDOSts(7) = 1 Then Me.Command_DO(Index).BackColor = RGB(192, 192, 192) Me.Command_DO(Index).Caption = "开关" + CStr(Index) + "[关]" bDOSts(7) = 0 Else Me.Command_DO(Index).Caption = "开关" + CStr(Index) + "[开]" Me.Command_DO(Index).BackColor = RGB(0, 255, 255) bDOSts(7) = 1 End If Case 8: If bDOSts(8) = 1 Then Me.Command_DO(Index).BackColor = RGB(192, 192, 192) Me.Command_DO(Index).Caption = "开关" + CStr(Index) + "[关]" bDOSts(8) = 0 Else Me.Command_DO(Index).Caption = "开关" + CStr(Index) + "[开]" Me.Command_DO(Index).BackColor = RGB(0, 255, 255) bDOSts(8) = 1 End If Case 9: If bDOSts(9) = 1 Then Me.Command_DO(Index).BackColor = RGB(192, 192, 192) Me.Command_DO(Index).Caption = "开关" + CStr(Index) + "[关]" bDOSts(9) = 0 Else Me.Command_DO(Index).Caption = "开关" + CStr(Index) + "[开]" Me.Command_DO(Index).BackColor = RGB(0, 255, 255) bDOSts(9) = 1 End If Case 10: If bDOSts(10) = 1 Then Me.Command_DO(Index).BackColor = RGB(192, 192, 192) Me.Command_DO(Index).Caption = "开关" + CStr(Index) + "[关]" bDOSts(10) = 0 Else Me.Command_DO(Index).Caption = "开关" + CStr(Index) + "[开]" Me.Command_DO(Index).BackColor = RGB(0, 255, 255) bDOSts(10) = 1 End If Case 11: If bDOSts(11) = 1 Then Me.Command_DO(Index).BackColor = RGB(192, 192, 192) Me.Command_DO(Index).Caption = "开关" + CStr(Index) + "[关]" bDOSts(11) = 0 Else Me.Command_DO(Index).Caption = "开关" + CStr(Index) + "[开]" Me.Command_DO(Index).BackColor = RGB(0, 255, 255) bDOSts(11) = 1 End If Case 12: If bDOSts(12) = 1 Then Me.Command_DO(Index).BackColor = RGB(192, 192, 192) Me.Command_DO(Index).Caption = "开关" + CStr(Index) + "[关]" bDOSts(12) = 0 Else Me.Command_DO(Index).Caption = "开关" + CStr(Index) + "[开]" Me.Command_DO(Index).BackColor = RGB(0, 255, 255) bDOSts(12) = 1 End If Case 13: If bDOSts(13) = 1 Then Me.Command_DO(Index).BackColor = RGB(192, 192, 192) Me.Command_DO(Index).Caption = "开关" + CStr(Index) + "[关]" bDOSts(13) = 0 Else Me.Command_DO(Index).Caption = "开关" + CStr(Index) + "[开]" Me.Command_DO(Index).BackColor = RGB(0, 255, 255) bDOSts(13) = 1 End If Case 14: If bDOSts(14) = 1 Then Me.Command_DO(Index).BackColor = RGB(192, 192, 192) Me.Command_DO(Index).Caption = "开关" + CStr(Index) + "[关]" bDOSts(14) = 0 Else Me.Command_DO(Index).Caption = "开关" + CStr(Index) + "[开]" Me.Command_DO(Index).BackColor = RGB(0, 255, 255) bDOSts(14) = 1 End If Case 15: If bDOSts(15) = 1 Then Me.Command_DO(Index).BackColor = RGB(192, 192, 192) Me.Command_DO(Index).Caption = "开关" + CStr(Index) + "[关]" bDOSts(15) = 0 Else Me.Command_DO(Index).Caption = "开关" + CStr(Index) + "[开]" Me.Command_DO(Index).BackColor = RGB(0, 255, 255) bDOSts(15) = 1 End If End Select If PCI2312_SetDeviceDO(hDevice, bDOSts(0)) = False Then ' 开关量输出 MsgBox "PCI2312_SetDeviceDO Error..." End If End Sub Private Sub Command_ReadDI_Click() If PCI2312_GetDeviceDI(hDevice, bDISts(0)) = False Then ' 开关量输入 MsgBox "PCI2312_GetDeviceDI Error..." End If If bDISts(0) = 1 Then Me.Command_DI(0).Caption = "开关0[开]" Me.Command_DI(0).BackColor = RGB(0, 255, 255) Else Me.Command_DI(0).Caption = "开关0[关]" Me.Command_DI(0).BackColor = RGB(192, 192, 192) End If If bDISts(1) = 1 Then Me.Command_DI(1).Caption = "开关1[开]" Me.Command_DI(1).BackColor = RGB(0, 255, 255) Else Me.Command_DI(1).Caption = "开关1[关]" Me.Command_DI(1).BackColor = RGB(192, 192, 192) End If If bDISts(2) = 1 Then Me.Command_DI(2).Caption = "开关2[开]" Me.Command_DI(2).BackColor = RGB(0, 255, 255) Else Me.Command_DI(2).Caption = "开关2[关]" Me.Command_DI(2).BackColor = RGB(192, 192, 192) End If If bDISts(3) = 1 Then Me.Command_DI(3).Caption = "开关3[开]" Me.Command_DI(3).BackColor = RGB(0, 255, 255) Else Me.Command_DI(3).Caption = "开关3[关]" Me.Command_DI(3).BackColor = RGB(192, 192, 192) End If If bDISts(4) = 1 Then Me.Command_DI(4).Caption = "开关4[开]" Me.Command_DI(4).BackColor = RGB(0, 255, 255) Else Me.Command_DI(4).Caption = "开关4[关]" Me.Command_DI(4).BackColor = RGB(192, 192, 192) End If If bDISts(5) = 1 Then Me.Command_DI(5).Caption = "开关5[开]" Me.Command_DI(5).BackColor = RGB(0, 255, 255) Else Me.Command_DI(5).Caption = "开关5[关]" Me.Command_DI(5).BackColor = RGB(192, 192, 192) End If If bDISts(6) = 1 Then Me.Command_DI(6).Caption = "开关6[开]" Me.Command_DI(6).BackColor = RGB(0, 255, 255) Else Me.Command_DI(6).Caption = "开关6[关]" Me.Command_DI(6).BackColor = RGB(192, 192, 192) End If If bDISts(7) = 1 Then Me.Command_DI(7).Caption = "开关7[开]" Me.Command_DI(7).BackColor = RGB(0, 255, 255) Else Me.Command_DI(7).Caption = "开关7[关]" Me.Command_DI(7).BackColor = RGB(192, 192, 192) End If If bDISts(8) = 1 Then Me.Command_DI(8).Caption = "开关8[开]" Me.Command_DI(8).BackColor = RGB(0, 255, 255) Else Me.Command_DI(8).Caption = "开关8[关]" Me.Command_DI(8).BackColor = RGB(192, 192, 192) End If If bDISts(9) = 1 Then Me.Command_DI(9).Caption = "开关9[开]" Me.Command_DI(9).BackColor = RGB(0, 255, 255) Else Me.Command_DI(9).Caption = "开关9[关]" Me.Command_DI(9).BackColor = RGB(192, 192, 192) End If If bDISts(10) = 1 Then Me.Command_DI(10).Caption = "开关10[开]" Me.Command_DI(10).BackColor = RGB(0, 255, 255) Else Me.Command_DI(10).Caption = "开关10[关]" Me.Command_DI(10).BackColor = RGB(192, 192, 192) End If If bDISts(11) = 1 Then Me.Command_DI(11).Caption = "开关11[开]" Me.Command_DI(11).BackColor = RGB(0, 255, 255) Else Me.Command_DI(11).Caption = "开关11[关]" Me.Command_DI(11).BackColor = RGB(192, 192, 192) End If If bDISts(12) = 1 Then Me.Command_DI(12).Caption = "开关12[开]" Me.Command_DI(12).BackColor = RGB(0, 255, 255) Else Me.Command_DI(12).Caption = "开关12[关]" Me.Command_DI(12).BackColor = RGB(192, 192, 192) End If If bDISts(13) = 1 Then Me.Command_DI(13).Caption = "开关13[开]" Me.Command_DI(13).BackColor = RGB(0, 255, 255) Else Me.Command_DI(13).Caption = "开关13[关]" Me.Command_DI(13).BackColor = RGB(192, 192, 192) End If If bDISts(14) = 1 Then Me.Command_DI(14).Caption = "开关14[开]" Me.Command_DI(14).BackColor = RGB(0, 255, 255) Else Me.Command_DI(14).Caption = "开关14[关]" Me.Command_DI(14).BackColor = RGB(192, 192, 192) End If If bDISts(15) = 1 Then Me.Command_DI(15).Caption = "开关15[开]" Me.Command_DI(15).BackColor = RGB(0, 255, 255) Else Me.Command_DI(15).Caption = "开关15[关]" Me.Command_DI(15).BackColor = RGB(192, 192, 192) End If End Sub Private Sub Form_Load() DeviceLgcID = 0 hDevice = PCI2312_CreateDevice(DeviceLgcID) If hDevice = INVALID_HANDLE_VALUE Then MsgBox "PCI2312_CreateDevice Error..." Exit Sub End If End Sub Private Sub Form_Unload(Cancel As Integer) If PCI2312_ReleaseDevice(hDevice) = False Then MsgBox "PCI2312_ReleaseDevice Error..." End If End Sub