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

📄 frmrun.frm

📁 16 relay output channels and 16 isolated digital input channels LED indicators to show activated
💻 FRM
📖 第 1 页 / 共 4 页
字号:
         Width           =   375
      End
      Begin VB.Label labBit 
         Alignment       =   2  'Center
         Appearance      =   0  'Flat
         BackColor       =   &H80000005&
         Caption         =   "D22"
         ForeColor       =   &H80000008&
         Height          =   255
         Index           =   49
         Left            =   720
         TabIndex        =   65
         Top             =   2520
         Width           =   375
      End
      Begin VB.Label labBit 
         Alignment       =   2  'Center
         Appearance      =   0  'Flat
         BackColor       =   &H80000005&
         Caption         =   "D23"
         ForeColor       =   &H80000008&
         Height          =   255
         Index           =   48
         Left            =   240
         TabIndex        =   64
         Top             =   2520
         Width           =   375
      End
      Begin VB.Label labBit 
         Alignment       =   1  'Right Justify
         Appearance      =   0  'Flat
         BackColor       =   &H80000005&
         Caption         =   "D9"
         ForeColor       =   &H80000008&
         Height          =   255
         Index           =   46
         Left            =   3240
         TabIndex        =   47
         Top             =   1680
         Width           =   255
      End
      Begin VB.Label labBit 
         Alignment       =   2  'Center
         Appearance      =   0  'Flat
         BackColor       =   &H80000005&
         Caption         =   "D10"
         ForeColor       =   &H80000008&
         Height          =   255
         Index           =   45
         Left            =   2760
         TabIndex        =   46
         Top             =   1680
         Width           =   375
      End
      Begin VB.Label labBit 
         Alignment       =   2  'Center
         Appearance      =   0  'Flat
         BackColor       =   &H80000005&
         Caption         =   "D11"
         ForeColor       =   &H80000008&
         Height          =   255
         Index           =   44
         Left            =   2280
         TabIndex        =   45
         Top             =   1680
         Width           =   375
      End
      Begin VB.Label labBit 
         Alignment       =   2  'Center
         Appearance      =   0  'Flat
         BackColor       =   &H80000005&
         Caption         =   "D12"
         ForeColor       =   &H80000008&
         Height          =   255
         Index           =   43
         Left            =   1680
         TabIndex        =   44
         Top             =   1680
         Width           =   375
      End
      Begin VB.Label labBit 
         Alignment       =   2  'Center
         Appearance      =   0  'Flat
         BackColor       =   &H80000005&
         Caption         =   "D13"
         ForeColor       =   &H80000008&
         Height          =   255
         Index           =   42
         Left            =   1200
         TabIndex        =   43
         Top             =   1680
         Width           =   375
      End
      Begin VB.Label labBit 
         Alignment       =   2  'Center
         Appearance      =   0  'Flat
         BackColor       =   &H80000005&
         Caption         =   "D14"
         ForeColor       =   &H80000008&
         Height          =   255
         Index           =   41
         Left            =   720
         TabIndex        =   42
         Top             =   1680
         Width           =   375
      End
      Begin VB.Label labBit 
         Alignment       =   2  'Center
         Appearance      =   0  'Flat
         BackColor       =   &H80000005&
         Caption         =   "D15"
         ForeColor       =   &H80000008&
         Height          =   255
         Index           =   40
         Left            =   240
         TabIndex        =   41
         Top             =   1680
         Width           =   375
      End
      Begin VB.Label labBit 
         Alignment       =   1  'Right Justify
         Appearance      =   0  'Flat
         BackColor       =   &H80000005&
         Caption         =   "D0"
         ForeColor       =   &H80000008&
         Height          =   255
         Index           =   39
         Left            =   3600
         TabIndex        =   25
         Top             =   840
         Width           =   375
      End
      Begin VB.Label labBit 
         Alignment       =   1  'Right Justify
         Appearance      =   0  'Flat
         BackColor       =   &H80000005&
         Caption         =   "D1"
         ForeColor       =   &H80000008&
         Height          =   255
         Index           =   38
         Left            =   3120
         TabIndex        =   24
         Top             =   840
         Width           =   375
      End
      Begin VB.Label labBit 
         Alignment       =   2  'Center
         Appearance      =   0  'Flat
         BackColor       =   &H80000005&
         Caption         =   "D2"
         ForeColor       =   &H80000008&
         Height          =   255
         Index           =   37
         Left            =   2760
         TabIndex        =   23
         Top             =   840
         Width           =   255
      End
      Begin VB.Label labBit 
         Alignment       =   2  'Center
         Appearance      =   0  'Flat
         BackColor       =   &H80000005&
         Caption         =   "D3"
         ForeColor       =   &H80000008&
         Height          =   255
         Index           =   36
         Left            =   2280
         TabIndex        =   22
         Top             =   840
         Width           =   255
      End
      Begin VB.Label labBit 
         Alignment       =   2  'Center
         Appearance      =   0  'Flat
         BackColor       =   &H80000005&
         Caption         =   "D4"
         ForeColor       =   &H80000008&
         Height          =   255
         Index           =   35
         Left            =   1680
         TabIndex        =   21
         Top             =   840
         Width           =   255
      End
      Begin VB.Label labBit 
         Alignment       =   2  'Center
         Appearance      =   0  'Flat
         BackColor       =   &H80000005&
         Caption         =   "D5"
         ForeColor       =   &H80000008&
         Height          =   255
         Index           =   34
         Left            =   1200
         TabIndex        =   20
         Top             =   840
         Width           =   255
      End
      Begin VB.Label labBit 
         Alignment       =   2  'Center
         Appearance      =   0  'Flat
         BackColor       =   &H80000005&
         Caption         =   "D6"
         ForeColor       =   &H80000008&
         Height          =   255
         Index           =   33
         Left            =   720
         TabIndex        =   19
         Top             =   840
         Width           =   255
      End
      Begin VB.Label labBit 
         Alignment       =   2  'Center
         Appearance      =   0  'Flat
         BackColor       =   &H80000005&
         Caption         =   "D7"
         ForeColor       =   &H80000008&
         Height          =   255
         Index           =   32
         Left            =   240
         TabIndex        =   18
         Top             =   840
         Width           =   255
      End
   End
   Begin VB.CommandButton cmdExit 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      Caption         =   "E&xit"
      Height          =   375
      Left            =   5040
      TabIndex        =   0
      Top             =   3480
      Width           =   1215
   End
   Begin VB.Frame Frame2 
      BackColor       =   &H80000009&
      Height          =   3855
      Left            =   4800
      TabIndex        =   102
      Top             =   120
      Width           =   1695
   End
End
Attribute VB_Name = "frmRun"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim DoValue As Double

Function DoBit(bit As Integer) As Double
  Dim i As Integer
  
  DoBit = 1
  If bit >= 1 Then
    For i = 1 To bit
      DoBit = DoBit * 2
    Next i
  End If
  
End Function

Private Sub cmdBit_Click(Index As Integer)
  Dim i As Integer
  
  cmdBit(Index).Visible = False
  pictureBit(Index).Visible = True
  
  DoValue = 0
  For i = 0 To 31
    If (pictureBit(i).Visible = True) Then
      DoValue = DoValue + DoBit(i)
    End If
  Next i
  
End Sub


Private Sub cmdExit_Click()
    frmRun.Hide
    frmDevSel.Show
    frmDevSel.cmdExit.SetFocus
End Sub


Private Sub cmdReadByte_Click()
  Dim DiValue As Long
  
  lpReadPortByte.Port = gwPort
  lpReadPortByte.ByteData = DRV_GetAddress(DiValue)

  ErrCde = DRV_ReadPortByte(DeviceHandle, lpReadPortByte)
  If (ErrCde <> 0) Then
        DRV_GetErrorMessage ErrCde, szErrMsg
        Response = MsgBox(szErrMsg, vbOKOnly, "Error!!")
        Exit Sub
  End If
  txtByte.Text = Hex(DiValue)

End Sub

Private Sub cmdReadDword_Click()
  Dim DiValue As Long
  
  lpReadPortDword.Port = gwPort
  lpReadPortDword.DwordData = DRV_GetAddress(DiValue)

  ErrCde = DRV_ReadPortDword(DeviceHandle, lpReadPortDword)
  If (ErrCde <> 0) Then
        DRV_GetErrorMessage ErrCde, szErrMsg
        Response = MsgBox(szErrMsg, vbOKOnly, "Error!!")
        Exit Sub
  End If
  txtDword.Text = Hex(DiValue)

End Sub

Private Sub cmdReadWord_Click()
  Dim DiValue As Long
  
  lpReadPortWord.Port = gwPort
  lpReadPortWord.WordData = DRV_GetAddress(DiValue)

  ErrCde = DRV_ReadPortWord(DeviceHandle, lpReadPortWord)
  If (ErrCde <> 0) Then
        DRV_GetErrorMessage ErrCde, szErrMsg
        Response = MsgBox(szErrMsg, vbOKOnly, "Error!!")
        Exit Sub
  End If
  txtWord.Text = Hex(DiValue)

End Sub

Private Sub cmdWriteByte_Click()
lpWritePortByte.Port = gwPort
If (DoValue > 255) Then
    lpWritePortByte.ByteData = 255
Else
    lpWritePortByte.ByteData = DoValue
End If
ErrCde = DRV_WritePortByte(DeviceHandle, lpWritePortByte)
If (ErrCde <> 0) Then
    DRV_GetErrorMessage ErrCde, szErrMsg
    Response = MsgBox(szErrMsg, vbOKOnly, "Error!!")
    Exit Sub
End If

End Sub

Private Sub cmdWriteDword_Click()
  lpWritePortDword.Port = gwPort
  If (DoValue > 2147483647) Then
     lpWritePortDword.DwordData = DoValue - 4294967296# 'because in memory, the MSB is the sign bit
  Else
     lpWritePortDword.DwordData = DoValue
  End If
  
  ErrCde = DRV_WritePortDword(DeviceHandle, lpWritePortDword)
  If (ErrCde <> 0) Then
        DRV_GetErrorMessage ErrCde, szErrMsg
        Response = MsgBox(szErrMsg, vbOKOnly, "Error!!")
        Exit Sub
  End If
End Sub

Private Sub cmdWriteWord_Click()
  lpWritePortWord.Port = gwPort
  
  If (DoValue > 65535) Then
    lpWritePortWord.WordData = &HFFFF
  ElseIf (DoValue > 32767) Then
    lpWritePortWord.WordData = DoValue - 65536  'because in memory, the MSB is the sign bit
  Else
    lpWritePortWord.WordData = DoValue
  End If
  
  ErrCde = DRV_WritePortWord(DeviceHandle, lpWritePortWord)
  If (ErrCde <> 0) Then
        DRV_GetErrorMessage ErrCde, szErrMsg
        Response = MsgBox(szErrMsg, vbOKOnly, "Error!!")
        Exit Sub
  End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
    frmDevSel.Show
End Sub

Private Sub pictureBit_Click(Index As Integer)
  Dim i As Integer
  
  cmdBit(Index).Visible = True
  pictureBit(Index).Visible = False
 
  DoValue = 0
  For i = 0 To 31
    If (pictureBit(i).Visible = True) Then
      DoValue = DoValue + DoBit(i)
    End If
  Next i
  
End Sub


⌨️ 快捷键说明

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