⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmdotester.frm

📁 使用研华DAQ实现研华数据采集卡的多种功能。包括数据输入输出等。内含多个源码
💻 FRM
📖 第 1 页 / 共 2 页
字号:
            Left            =   2400
            Shape           =   3  'Circle
            Top             =   360
            Width           =   255
         End
         Begin VB.Shape spMask 
            FillColor       =   &H0000FF00&
            FillStyle       =   0  'Solid
            Height          =   255
            Index           =   3
            Left            =   2925
            Shape           =   3  'Circle
            Top             =   360
            Width           =   255
         End
         Begin VB.Shape spMask 
            FillColor       =   &H0000FF00&
            FillStyle       =   0  'Solid
            Height          =   255
            Index           =   2
            Left            =   3405
            Shape           =   3  'Circle
            Top             =   360
            Width           =   255
         End
         Begin VB.Shape spMask 
            FillColor       =   &H0000FF00&
            FillStyle       =   0  'Solid
            Height          =   255
            Index           =   1
            Left            =   3885
            Shape           =   3  'Circle
            Top             =   360
            Width           =   255
         End
         Begin VB.Shape spMask 
            FillColor       =   &H0000FF00&
            FillStyle       =   0  'Solid
            Height          =   255
            Index           =   0
            Left            =   4365
            Shape           =   3  'Circle
            Top             =   360
            Width           =   255
         End
         Begin VB.Label labBit 
            Alignment       =   1  'Right Justify
            Appearance      =   0  'Flat
            BackColor       =   &H8000000A&
            Caption         =   "7"
            ForeColor       =   &H80000008&
            Height          =   255
            Index           =   7
            Left            =   975
            TabIndex        =   31
            Top             =   1230
            Width           =   225
         End
         Begin VB.Label labBit 
            Alignment       =   1  'Right Justify
            Appearance      =   0  'Flat
            BackColor       =   &H8000000A&
            Caption         =   "6"
            ForeColor       =   &H80000008&
            Height          =   255
            Index           =   6
            Left            =   1455
            TabIndex        =   30
            Top             =   1230
            Width           =   225
         End
         Begin VB.Label labBit 
            Alignment       =   1  'Right Justify
            Appearance      =   0  'Flat
            BackColor       =   &H8000000A&
            Caption         =   "5"
            ForeColor       =   &H80000008&
            Height          =   255
            Index           =   5
            Left            =   1935
            TabIndex        =   29
            Top             =   1230
            Width           =   225
         End
         Begin VB.Label labBit 
            Alignment       =   1  'Right Justify
            Appearance      =   0  'Flat
            BackColor       =   &H8000000A&
            Caption         =   "4"
            ForeColor       =   &H80000008&
            Height          =   255
            Index           =   4
            Left            =   2415
            TabIndex        =   28
            Top             =   1230
            Width           =   225
         End
         Begin VB.Label labBit 
            Alignment       =   1  'Right Justify
            Appearance      =   0  'Flat
            BackColor       =   &H8000000A&
            Caption         =   "3"
            ForeColor       =   &H80000008&
            Height          =   255
            Index           =   3
            Left            =   2895
            TabIndex        =   27
            Top             =   1230
            Width           =   225
         End
         Begin VB.Label labBit 
            Alignment       =   1  'Right Justify
            Appearance      =   0  'Flat
            BackColor       =   &H8000000A&
            Caption         =   "2"
            ForeColor       =   &H80000008&
            Height          =   255
            Index           =   2
            Left            =   3375
            TabIndex        =   26
            Top             =   1230
            Width           =   225
         End
         Begin VB.Label labBit 
            Alignment       =   1  'Right Justify
            Appearance      =   0  'Flat
            BackColor       =   &H8000000A&
            Caption         =   "1"
            ForeColor       =   &H80000008&
            Height          =   255
            Index           =   1
            Left            =   3855
            TabIndex        =   25
            Top             =   1230
            Width           =   225
         End
         Begin VB.Label labBit 
            Alignment       =   1  'Right Justify
            Appearance      =   0  'Flat
            BackColor       =   &H8000000A&
            Caption         =   "0"
            ForeColor       =   &H80000008&
            Height          =   255
            Index           =   0
            Left            =   4335
            TabIndex        =   24
            Top             =   1230
            Width           =   225
         End
      End
   End
   Begin VB.Frame Frame1 
      Caption         =   "Select Device :"
      Height          =   1332
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   5265
      Begin VB.TextBox txtDeviceNum 
         Height          =   288
         Left            =   1200
         TabIndex        =   3
         Text            =   "-1"
         ToolTipText     =   "Device Number"
         Top             =   360
         Width           =   972
      End
      Begin VB.TextBox txtDeviceName 
         Height          =   285
         Left            =   1200
         TabIndex        =   2
         Text            =   "Advantech"
         ToolTipText     =   "Device Name"
         Top             =   840
         Width           =   3735
      End
      Begin VB.CommandButton cmdSelectDevice 
         Caption         =   "&Select Device"
         Default         =   -1  'True
         Height          =   375
         Left            =   3600
         TabIndex        =   1
         ToolTipText     =   "Selecting device to operation"
         Top             =   310
         Width           =   1335
      End
      Begin VB.Label Label1 
         AutoSize        =   -1  'True
         Caption         =   "Device No. :"
         Height          =   192
         Left            =   120
         TabIndex        =   5
         Top             =   360
         Width           =   900
      End
      Begin VB.Label Label2 
         AutoSize        =   -1  'True
         Caption         =   "Device Name :"
         Height          =   192
         Left            =   120
         TabIndex        =   4
         Top             =   840
         Width           =   1068
      End
   End
   Begin DAQDOLib.DAQDO DAQDO1 
      Height          =   1125
      Left            =   6240
      TabIndex        =   42
      Top             =   240
      Width           =   3000
      _Version        =   65537
      _ExtentX        =   864
      _ExtentY        =   864
      _StockProps     =   0
      MaxPortNumber   =   0
   End
End
Attribute VB_Name = "frmDoTester"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public bOpen As Boolean

Private Sub UpdateDisplay()
   Dim iValue As Integer
   Dim i As Integer

   ' Get status back
   iValue = DAQDO1.ByteReadBack
   ' Update Display State
   txtReadBack.Text = Hex(iValue)
   For i = 0 To 7
      iState = iValue Mod 2
      iValue = (iValue - iState) / 2
      If iState = 0 Then
         cmdChannelON(i).Visible = False
         cmdChannelOFF(i).Visible = True
      Else
         cmdChannelON(i).Visible = True
         cmdChannelOFF(i).Visible = False
      End If
   Next i
End Sub

Private Sub cmbPort_Click()
   DAQDO1.Port = cmbPort.ListIndex
   cmdReadBack_Click
End Sub

Private Sub cmdByteOut_Click()
   DAQDO1.Mask = CInt("&H" + txtMask.Text)
   DAQDO1.ByteOutput (CInt("&H" + txtReadBack.Text))
End Sub

Private Sub cmdChannelON_Click(Index As Integer)
   DAQDO1.Bit = Index
   DAQDO1.BitOutput (False)
   
   cmdChannelON(Index).Visible = False
   cmdChannelOFF(Index).Visible = True
End Sub

Private Sub cmdChannelOFF_Click(Index As Integer)
   DAQDO1.Bit = Index
   DAQDO1.BitOutput (True)
        
   cmdChannelON(Index).Visible = True
   cmdChannelOFF(Index).Visible = False
End Sub

Private Sub cmdExit_Click()
   If bOpen Then
      DAQDO1.CloseDevice
   End If
   
   Unload Me
   End
End Sub

Private Sub cmdReadBack_Click()
   ' Update Display State
   Call UpdateDisplay
End Sub

Private Sub cmdSelectDevice_Click()
   Dim Ret As Long
   
   If bOpen Then
      DAQDO1.CloseDevice
      bOpen = False
      framPort.Enabled = False
      cmbPort.Enabled = False
   End If
   
   ' Select Device from installed list
   Ret = DAQDO1.SelectDevice
   txtDeviceNum.Text = DAQDO1.DeviceNumber
   txtDeviceName.Text = DAQDO1.DeviceName
   DAQDO1.DeviceNumber = DAQDO1.DeviceNumber
   DAQDO1.DeviceName = DAQDO1.DeviceName
   
   ' Open Device
   If DAQDO1.OpenDevice Then
      MsgBox DAQDO1.ErrorMessage, vbOKOnly
      Exit Sub
   End If

    If DAQDO1.MaxPortNumber = 0 Then
        MsgBox "Function Not Supported", vbOKOnly
        Unload Me
        End
    End If
   framPort.Enabled = True
   cmbPort.Enabled = True
   bOpen = True
   ' Add Port number to list box
   cmbPort.Clear
   For i = 0 To DAQDO1.MaxPortNumber - 1
      cmbPort.AddItem (Str(i))
   Next i
   If DAQDO1.MaxPortNumber Then
      cmbPort.ListIndex = DAQDO1.Port
   End If
End Sub

Private Sub Form_Load()
   Dim i As Integer
   'Dim Ret As Long
   'Select Default Device
   Call cmdSelectDevice_Click
   
   DAQDO1.Mask = &HFF
End Sub

Private Sub Label6_Click()

End Sub

Private Sub txtMask_Change()
   DAQDO1.Mask = CInt("&H" + txtMask.Text)
   Call UpdateMask
End Sub

Private Sub UpdateMask()
   Dim iValue As Integer
   Dim i As Integer

   ' Get status back
   iValue = DAQDO1.Mask
   For i = 0 To 7
      iState = iValue Mod 2
      iValue = (iValue - iState) / 2
      If iState = 0 Then
         spMask(i).FillColor = &HFF&
      Else
         spMask(i).FillColor = &HFF00&
      End If
   Next i
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -