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

📄 frmplset.frm

📁 一个modbus的测试工具
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmPLSet 
   BorderStyle     =   4  'Fixed ToolWindow
   Caption         =   "协议参数设置"
   ClientHeight    =   4155
   ClientLeft      =   45
   ClientTop       =   285
   ClientWidth     =   6345
   BeginProperty Font 
      Name            =   "宋体"
      Size            =   9.75
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   4155
   ScaleWidth      =   6345
   ShowInTaskbar   =   0   'False
   StartUpPosition =   1  'CenterOwner
   Begin VB.Frame Frame3 
      Caption         =   "参考地址"
      Height          =   2895
      Left            =   3120
      TabIndex        =   15
      Top             =   600
      Width           =   3015
      Begin VB.TextBox txtPresetRegAddress 
         Height          =   285
         Left            =   1680
         TabIndex        =   26
         Text            =   "0"
         Top             =   2520
         Width           =   1215
      End
      Begin VB.TextBox txtForceCoilAddress 
         Height          =   285
         Left            =   1680
         TabIndex        =   24
         Text            =   "0"
         Top             =   2160
         Width           =   1215
      End
      Begin VB.TextBox txtInputRegAddress 
         Height          =   285
         Left            =   1680
         TabIndex        =   22
         Text            =   "0"
         Top             =   1320
         Width           =   1215
      End
      Begin VB.TextBox txtHoldRegAddress 
         Height          =   285
         Left            =   1680
         TabIndex        =   20
         Text            =   "0"
         Top             =   960
         Width           =   1215
      End
      Begin VB.TextBox txtInputAddress 
         Height          =   285
         Left            =   1680
         TabIndex        =   18
         Text            =   "0"
         Top             =   600
         Width           =   1215
      End
      Begin VB.TextBox txtCoilAddress 
         Height          =   285
         Left            =   1680
         TabIndex        =   16
         Text            =   "0"
         Top             =   240
         Width           =   1215
      End
      Begin VB.Label Label9 
         AutoSize        =   -1  'True
         Caption         =   "Preset REG."
         Height          =   195
         Left            =   120
         TabIndex        =   27
         Top             =   2520
         Width           =   1155
      End
      Begin VB.Label Label8 
         AutoSize        =   -1  'True
         Caption         =   "Force Coil"
         Height          =   195
         Left            =   120
         TabIndex        =   25
         Top             =   2160
         Width           =   1050
      End
      Begin VB.Label Label7 
         AutoSize        =   -1  'True
         Caption         =   "Input REG."
         Height          =   195
         Left            =   120
         TabIndex        =   23
         Top             =   1320
         Width           =   1050
      End
      Begin VB.Label Label6 
         AutoSize        =   -1  'True
         Caption         =   "Holding REG."
         Height          =   195
         Left            =   120
         TabIndex        =   21
         Top             =   960
         Width           =   1260
      End
      Begin VB.Label Label5 
         AutoSize        =   -1  'True
         Caption         =   "Input"
         Height          =   195
         Left            =   120
         TabIndex        =   19
         Top             =   600
         Width           =   525
      End
      Begin VB.Label Label4 
         AutoSize        =   -1  'True
         Caption         =   "Coil"
         Height          =   195
         Left            =   120
         TabIndex        =   17
         Top             =   240
         Width           =   420
      End
   End
   Begin VB.TextBox txtScan 
      Height          =   285
      Left            =   5280
      TabIndex        =   12
      Text            =   "500"
      Top             =   240
      Width           =   615
   End
   Begin VB.Frame Frame2 
      Caption         =   "校验方式"
      Height          =   1695
      Left            =   240
      TabIndex        =   7
      Top             =   2160
      Width           =   2655
      Begin VB.OptionButton optCheckMode 
         Caption         =   "LRC"
         Height          =   255
         Index           =   3
         Left            =   360
         TabIndex        =   11
         Top             =   1080
         Width           =   1815
      End
      Begin VB.OptionButton optCheckMode 
         Caption         =   "CRC2"
         Enabled         =   0   'False
         Height          =   255
         Index           =   2
         Left            =   360
         TabIndex        =   10
         Top             =   840
         Width           =   1815
      End
      Begin VB.OptionButton optCheckMode 
         Caption         =   "CRC1"
         Height          =   255
         Index           =   1
         Left            =   360
         TabIndex        =   9
         Top             =   600
         Width           =   1815
      End
      Begin VB.OptionButton optCheckMode 
         Caption         =   "不校验"
         Enabled         =   0   'False
         Height          =   255
         Index           =   0
         Left            =   360
         TabIndex        =   8
         Top             =   360
         Value           =   -1  'True
         Width           =   1815
      End
   End
   Begin VB.Frame Frame1 
      Caption         =   "协议帧方式"
      Height          =   1335
      Left            =   240
      TabIndex        =   4
      Top             =   720
      Width           =   2655
      Begin VB.OptionButton optFrameType 
         Caption         =   "RTU"
         Height          =   255
         Index           =   1
         Left            =   360
         TabIndex        =   6
         Top             =   720
         Value           =   -1  'True
         Width           =   1935
      End
      Begin VB.OptionButton optFrameType 
         Caption         =   "ASCII"
         Height          =   255
         Index           =   0
         Left            =   360
         TabIndex        =   5
         Top             =   360
         Width           =   1935
      End
   End
   Begin VB.TextBox txtAddress 
      Height          =   285
      Left            =   2280
      TabIndex        =   3
      Text            =   "1"
      Top             =   240
      Width           =   615
   End
   Begin VB.CommandButton cmdCancel 
      Cancel          =   -1  'True
      Caption         =   "取  消"
      Height          =   375
      Left            =   4560
      TabIndex        =   1
      Top             =   3600
      Width           =   1095
   End
   Begin VB.CommandButton cmdOK 
      Caption         =   "确  认"
      Height          =   375
      Left            =   3360
      TabIndex        =   0
      Top             =   3600
      Width           =   1095
   End
   Begin VB.Label Label3 
      AutoSize        =   -1  'True
      Caption         =   "ms"
      Height          =   195
      Left            =   6000
      TabIndex        =   14
      Top             =   240
      Width           =   210
   End
   Begin VB.Label Label2 
      AutoSize        =   -1  'True
      Caption         =   "扫描周期(200-1000)"
      Height          =   195
      Left            =   3120
      TabIndex        =   13
      Top             =   240
      Width           =   2100
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      Caption         =   "本站地址(1-247)"
      Height          =   195
      Left            =   240
      TabIndex        =   2
      Top             =   240
      Width           =   1785
   End
End
Attribute VB_Name = "frmPLSet"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Sub cmdCancel_Click()
    Unload Me
End Sub

Private Sub cmdOK_Click()
    If Val(txtAddress.Text) < 1 Or Val(txtAddress.Text) > 247 Then
        MsgBox "地址输入错误,范围为1-247", vbOKOnly + vbCritical, "告警"
        txtAddress.Text = gtPLSet.byAddress
        txtAddress.SetFocus
        Exit Sub
    End If
    If Val(txtScan.Text) < 200 Or Val(txtScan.Text) > 1000 Then
        MsgBox "扫描周期输入错误,范围为200-1000", vbOKOnly + vbCritical, "告警"
        txtScan.Text = gtPLSet.iScan
        txtScan.SetFocus
        Exit Sub
    End If
    If Val(txtCoilAddress.Text) < 0 Or Val(txtCoilAddress.Text) > 65536 - gcMAXCOIL Then
        MsgBox "Coil地址输入错误,范围为0-" & Str$(65536 - gcMAXCOIL), vbOKOnly + vbCritical, "告警"
        txtCoilAddress.Text = gtPLSet.iCoilAddress
        txtCoilAddress.SetFocus
        Exit Sub
    End If
    If Val(txtInputAddress.Text) < 0 Or Val(txtInputAddress.Text) > 65536 - gcMAXINPUT Then
        MsgBox "Input地址输入错误,范围为0-" & Str$(65536 - gcMAXINPUT), vbOKOnly + vbCritical, "告警"
        txtInputAddress.Text = gtPLSet.iInputAddress
        txtInputAddress.SetFocus
        Exit Sub
    End If
    If Val(txtHoldRegAddress.Text) < 0 Or Val(txtHoldRegAddress.Text) > 65536 - gcMAXHOLDREG Then
        MsgBox "Holding REG地址输入错误,范围为0-" & Str$(65536 - gcMAXHOLDREG), vbOKOnly + vbCritical, "告警"
        txtHoldRegAddress.Text = gtPLSet.iHoldRegAddress
        txtHoldRegAddress.SetFocus
        Exit Sub
    End If
    If Val(txtInputRegAddress.Text) < 0 Or Val(txtInputRegAddress.Text) > 65536 - gcMAXINPUTREG Then
        MsgBox "Input REG地址输入错误,范围为0-" & Str$(65536 - gcMAXINPUTREG), vbOKOnly + vbCritical, "告警"
        txtInputRegAddress.Text = gtPLSet.iInputRegAddress
        txtInputRegAddress.SetFocus
        Exit Sub
    End If
    If Val(txtForceCoilAddress.Text) < 0 Or Val(txtForceCoilAddress.Text) > 65536 - gcMAXFORCECOIL Then
        MsgBox "Force Coil地址输入错误,范围为0-" & Str$(65536 - gcMAXFORCECOIL), vbOKOnly + vbCritical, "告警"
        txtForceCoilAddress.Text = gtPLSet.iForceCoilAddress
        txtForceCoilAddress.SetFocus
        Exit Sub
    End If
    If Val(txtPresetRegAddress.Text) < 0 Or Val(txtPresetRegAddress.Text) > 65536 - gcMAXPRESETREG Then
        MsgBox "Preset REG地址输入错误,范围为0-" & Str$(65536 - gcMAXPRESETREG), vbOKOnly + vbCritical, "告警"
        txtPresetRegAddress.Text = gtPLSet.iPresetRegAddress
        txtPresetRegAddress.SetFocus
        Exit Sub
    End If
    
    gtPLSet.byAddress = Val(txtAddress.Text)
    If optFrameType(0).Value = True Then
        gtPLSet.byFrameType = 0
    Else
        gtPLSet.byFrameType = 1
    End If
    If optCheckMode(0).Value = True Then
        gtPLSet.byCheckMode = 0
        gtPLSet.byCRCByte = 0
    ElseIf optCheckMode(1).Value = True Then
        gtPLSet.byCheckMode = 1
        gtPLSet.byCRCByte = 2
    ElseIf optCheckMode(2).Value = True Then
        gtPLSet.byCheckMode = 2
        gtPLSet.byCRCByte = 2
    Else
        gtPLSet.byCheckMode = 3
        gtPLSet.byCRCByte = 2
    End If
    gtPLSet.iScan = Val(txtScan.Text)
    gtPLSet.iCoilAddress = Val(txtCoilAddress.Text)
    gtPLSet.iInputAddress = Val(txtInputAddress.Text)
    gtPLSet.iHoldRegAddress = Val(txtHoldRegAddress.Text)
    gtPLSet.iInputRegAddress = Val(txtInputRegAddress.Text)
    gtPLSet.iForceCoilAddress = Val(txtForceCoilAddress.Text)
    gtPLSet.iPresetRegAddress = Val(txtPresetRegAddress.Text)
    Call gsubSaveINI
    Unload Me
End Sub

Private Sub Form_Load()
    Dim i As Integer
    
    txtAddress.Text = gtPLSet.byAddress
    optFrameType(gtPLSet.byFrameType).Value = True
    Call optFrameType_Click(Val(gtPLSet.byFrameType))
    optCheckMode(gtPLSet.byCheckMode).Value = True
    txtScan.Text = gtPLSet.iScan
    txtCoilAddress.Text = gtPLSet.iCoilAddress
    txtInputAddress.Text = gtPLSet.iInputAddress
    txtHoldRegAddress.Text = gtPLSet.iHoldRegAddress
    txtInputRegAddress.Text = gtPLSet.iInputRegAddress
    txtForceCoilAddress.Text = gtPLSet.iForceCoilAddress
    txtPresetRegAddress.Text = gtPLSet.iPresetRegAddress
End Sub

Private Sub optFrameType_Click(Index As Integer)
    If Index = 0 Then
        optCheckMode(1).Enabled = False
        optCheckMode(2).Enabled = False
        optCheckMode(0).Enabled = True
        optCheckMode(3).Enabled = True
        optCheckMode(3).Value = True
    Else
        optCheckMode(3).Enabled = False
        optCheckMode(0).Enabled = True
        optCheckMode(1).Enabled = True
        optCheckMode(2).Enabled = True
        optCheckMode(1).Value = True
    End If
End Sub

⌨️ 快捷键说明

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