pmcfg.frm

来自「16 relay output channels and 16 isolated」· FRM 代码 · 共 907 行 · 第 1/2 页

FRM
907
字号
            Value           =   -1  'True
            Width           =   225
         End
      End
      Begin VB.Frame Frame2 
         BorderStyle     =   0  'None
         Height          =   645
         Index           =   6
         Left            =   3465
         TabIndex        =   38
         Top             =   735
         Width           =   435
         Begin VB.OptionButton radHighPA0 
            Enabled         =   0   'False
            Height          =   225
            Index           =   6
            Left            =   105
            TabIndex        =   40
            Top             =   105
            Width           =   225
         End
         Begin VB.OptionButton radLowPA0 
            Enabled         =   0   'False
            Height          =   225
            Index           =   6
            Left            =   105
            TabIndex        =   39
            Top             =   420
            Value           =   -1  'True
            Width           =   225
         End
      End
      Begin VB.Frame Frame2 
         BorderStyle     =   0  'None
         Height          =   645
         Index           =   5
         Left            =   3045
         TabIndex        =   35
         Top             =   735
         Width           =   435
         Begin VB.OptionButton radHighPA0 
            Enabled         =   0   'False
            Height          =   225
            Index           =   5
            Left            =   105
            TabIndex        =   37
            Top             =   105
            Width           =   225
         End
         Begin VB.OptionButton radLowPA0 
            Enabled         =   0   'False
            Height          =   225
            Index           =   5
            Left            =   105
            TabIndex        =   36
            Top             =   420
            Value           =   -1  'True
            Width           =   225
         End
      End
      Begin VB.Frame Frame2 
         BorderStyle     =   0  'None
         Height          =   645
         Index           =   4
         Left            =   2625
         TabIndex        =   32
         Top             =   735
         Width           =   435
         Begin VB.OptionButton radHighPA0 
            Enabled         =   0   'False
            Height          =   225
            Index           =   4
            Left            =   105
            TabIndex        =   34
            Top             =   105
            Width           =   225
         End
         Begin VB.OptionButton radLowPA0 
            Enabled         =   0   'False
            Height          =   225
            Index           =   4
            Left            =   105
            TabIndex        =   33
            Top             =   420
            Value           =   -1  'True
            Width           =   225
         End
      End
      Begin VB.Frame Frame2 
         BorderStyle     =   0  'None
         Height          =   645
         Index           =   3
         Left            =   2205
         TabIndex        =   29
         Top             =   735
         Width           =   435
         Begin VB.OptionButton radHighPA0 
            Enabled         =   0   'False
            Height          =   225
            Index           =   3
            Left            =   105
            TabIndex        =   31
            Top             =   105
            Width           =   225
         End
         Begin VB.OptionButton radLowPA0 
            Enabled         =   0   'False
            Height          =   225
            Index           =   3
            Left            =   105
            TabIndex        =   30
            Top             =   420
            Value           =   -1  'True
            Width           =   225
         End
      End
      Begin VB.Frame Frame2 
         BorderStyle     =   0  'None
         Height          =   645
         Index           =   2
         Left            =   1785
         TabIndex        =   26
         Top             =   735
         Width           =   435
         Begin VB.OptionButton radLowPA0 
            Enabled         =   0   'False
            Height          =   225
            Index           =   2
            Left            =   105
            TabIndex        =   28
            Top             =   420
            Value           =   -1  'True
            Width           =   225
         End
         Begin VB.OptionButton radHighPA0 
            Enabled         =   0   'False
            Height          =   225
            Index           =   2
            Left            =   105
            TabIndex        =   27
            Top             =   105
            Width           =   225
         End
      End
      Begin VB.Frame Frame2 
         BorderStyle     =   0  'None
         Height          =   645
         Index           =   1
         Left            =   1365
         TabIndex        =   21
         Top             =   735
         Width           =   435
         Begin VB.OptionButton radHighPA0 
            Enabled         =   0   'False
            Height          =   225
            Index           =   1
            Left            =   105
            TabIndex        =   23
            Top             =   105
            Width           =   225
         End
         Begin VB.OptionButton radLowPA0 
            Enabled         =   0   'False
            Height          =   225
            Index           =   1
            Left            =   105
            TabIndex        =   22
            Top             =   420
            Value           =   -1  'True
            Width           =   225
         End
      End
      Begin VB.Frame Frame2 
         BorderStyle     =   0  'None
         Height          =   645
         Index           =   0
         Left            =   945
         TabIndex        =   18
         Top             =   735
         Width           =   435
         Begin VB.OptionButton radLowPA0 
            Enabled         =   0   'False
            Height          =   225
            Index           =   0
            Left            =   105
            TabIndex        =   20
            Top             =   420
            Value           =   -1  'True
            Width           =   225
         End
         Begin VB.OptionButton radHighPA0 
            Enabled         =   0   'False
            Height          =   225
            Index           =   0
            Left            =   105
            TabIndex        =   19
            Top             =   105
            Width           =   225
         End
      End
      Begin VB.CheckBox chkEnablePA0 
         Height          =   225
         Index           =   7
         Left            =   3990
         TabIndex        =   17
         Top             =   525
         Width           =   225
      End
      Begin VB.CheckBox chkEnablePA0 
         Height          =   225
         Index           =   6
         Left            =   3570
         TabIndex        =   16
         Top             =   525
         Width           =   225
      End
      Begin VB.CheckBox chkEnablePA0 
         Height          =   225
         Index           =   5
         Left            =   3150
         TabIndex        =   15
         Top             =   525
         Width           =   225
      End
      Begin VB.CheckBox chkEnablePA0 
         Height          =   225
         Index           =   4
         Left            =   2730
         TabIndex        =   14
         Top             =   525
         Width           =   225
      End
      Begin VB.CheckBox chkEnablePA0 
         Height          =   225
         Index           =   3
         Left            =   2310
         TabIndex        =   13
         Top             =   525
         Width           =   225
      End
      Begin VB.CheckBox chkEnablePA0 
         Height          =   225
         Index           =   2
         Left            =   1890
         TabIndex        =   12
         Top             =   525
         Width           =   225
      End
      Begin VB.CheckBox chkEnablePA0 
         Height          =   225
         Index           =   1
         Left            =   1470
         TabIndex        =   11
         Top             =   525
         Width           =   225
      End
      Begin VB.CheckBox chkEnablePA0 
         Height          =   225
         Index           =   0
         Left            =   1050
         TabIndex        =   10
         Top             =   525
         Width           =   225
      End
      Begin VB.Label Label4 
         Caption         =   "Low"
         Height          =   225
         Left            =   210
         TabIndex        =   25
         Top             =   1155
         Width           =   540
      End
      Begin VB.Label Label3 
         Caption         =   "High"
         Height          =   225
         Left            =   210
         TabIndex        =   24
         Top             =   840
         Width           =   540
      End
      Begin VB.Label Label2 
         Caption         =   "Bit7"
         Height          =   225
         Index           =   7
         Left            =   3990
         TabIndex        =   9
         Top             =   210
         Width           =   330
      End
      Begin VB.Label Label2 
         Caption         =   "Bit6"
         Height          =   225
         Index           =   6
         Left            =   3570
         TabIndex        =   8
         Top             =   210
         Width           =   330
      End
      Begin VB.Label Label2 
         Caption         =   "Bit5"
         Height          =   225
         Index           =   5
         Left            =   3150
         TabIndex        =   7
         Top             =   210
         Width           =   330
      End
      Begin VB.Label Label2 
         Caption         =   "Bit4"
         Height          =   225
         Index           =   4
         Left            =   2730
         TabIndex        =   6
         Top             =   210
         Width           =   330
      End
      Begin VB.Label Label2 
         Caption         =   "Bit3"
         Height          =   225
         Index           =   3
         Left            =   2310
         TabIndex        =   5
         Top             =   210
         Width           =   330
      End
      Begin VB.Label Label2 
         Caption         =   "Bit2"
         Height          =   225
         Index           =   2
         Left            =   1890
         TabIndex        =   4
         Top             =   210
         Width           =   330
      End
      Begin VB.Label Label2 
         Caption         =   "Bit1"
         Height          =   225
         Index           =   1
         Left            =   1470
         TabIndex        =   3
         Top             =   210
         Width           =   330
      End
      Begin VB.Label Label2 
         Caption         =   "Bit0"
         Height          =   225
         Index           =   0
         Left            =   1050
         TabIndex        =   2
         Top             =   210
         Width           =   330
      End
      Begin VB.Label Label1 
         Caption         =   "Enable:"
         Height          =   225
         Left            =   210
         TabIndex        =   1
         Top             =   525
         Width           =   540
      End
   End
End
Attribute VB_Name = "fPMConfig"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Public giPA0Value As Integer
Public giPA0Mask  As Integer
Public giPA4Value As Integer
Public giPA4Mask  As Integer

Private Sub chkEnablePA0_Click(Index As Integer)
    radHighPA0(Index).Enabled = chkEnablePA0(Index).Value
    radLowPA0(Index).Enabled = chkEnablePA0(Index).Value
End Sub

Private Sub chkEnablePA4_Click(Index As Integer)
    radHighPA4(Index).Enabled = chkEnablePA4(Index).Value
    radLowPA4(Index).Enabled = chkEnablePA4(Index).Value
End Sub

Private Sub cmdCancel_Click()
    Unload Me
End Sub

Private Sub cmdOk_Click()
Dim i As Integer

    'Read user setting in PA0
    giPA0Mask = 0
    giPA0Value = 0
    For i = 7 To 0 Step -1
        'Shift 1 bit left
        giPA0Mask = giPA0Mask * 2
        giPA0Value = giPA0Value * 2
        
        'Accumulate setting to public variable
        giPA0Mask = giPA0Mask + chkEnablePA0(i).Value
        If radHighPA0(i).Value = True Then
            giPA0Value = giPA0Value + 1
        End If
        
    Next i
        
    'Read user setting in PA4
    giPA4Mask = 0
    giPA4Value = 0
    For i = 7 To 0 Step -1
        'Shift 1 bit left
        giPA4Mask = giPA4Mask * 2
        giPA4Value = giPA4Value * 2
        
        'Accumulate setting to public variable
        giPA4Mask = giPA4Mask + chkEnablePA4(i).Value
        If radHighPA4(i).Value = True Then
            giPA4Value = giPA4Value + 1
        End If
    Next i
    
    Unload Me
End Sub

Private Sub Form_Activate()
Dim iMask, iValue, i As Integer

    'Setting default configuration for Port A0
    iMask = giPA0Mask
    iValue = giPA0Value
    For i = 0 To 7
        chkEnablePA0(i).Value = iMask And 1
        radHighPA0(i).Value = ((iValue And 1) = 1)
        radLowPA0(i).Value = ((iValue And 1) = 0)
        iMask = iMask \ 2
        iValue = iValue \ 2
    Next i
        
    'Setting default configuration for Port A4
    iMask = giPA4Mask
    iValue = giPA4Value
    For i = 0 To 7
        chkEnablePA4(i).Value = iMask And 1
        radHighPA4(i).Value = ((iValue And 1) = 1)
        radLowPA4(i).Value = ((iValue And 1) = 0)
        iMask = iMask \ 2
        iValue = iValue \ 2
    Next i

End Sub

⌨️ 快捷键说明

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