📄 frmsetting.frm
字号:
VERSION 5.00
Begin VB.Form frmSetting
BorderStyle = 3 'Fixed Dialog
Caption = "设置参数"
ClientHeight = 3780
ClientLeft = 45
ClientTop = 435
ClientWidth = 7005
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3780
ScaleWidth = 7005
ShowInTaskbar = 0 'False
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton cmdCancel
Caption = "取消"
Height = 375
Left = 3960
TabIndex = 9
Top = 2880
Width = 1335
End
Begin VB.CommandButton cmdOK
Caption = "确定"
Height = 375
Left = 1440
TabIndex = 8
Top = 2880
Width = 1335
End
Begin VB.Frame Frame1
Height = 1815
Left = 240
TabIndex = 0
Top = 480
Width = 6255
Begin VB.TextBox txtTime
Height = 270
Left = 1680
TabIndex = 6
Text = "Text3"
Top = 1200
Width = 660
End
Begin VB.TextBox txtSetting
Height = 270
Left = 4680
TabIndex = 4
Text = "Text2"
Top = 360
Width = 735
End
Begin VB.TextBox txtPort
Height = 270
Left = 2640
TabIndex = 3
Text = "Text1"
Top = 360
Width = 495
End
Begin VB.Label Label4
Caption = "ms发送一次"
Height = 255
Left = 2400
TabIndex = 7
Top = 1200
Width = 1215
End
Begin VB.Label Label3
Caption = "所用时间间隔"
Height = 255
Left = 240
TabIndex = 5
Top = 1200
Width = 1215
End
Begin VB.Label Label2
Caption = "串口设置"
Height = 270
Left = 3720
TabIndex = 2
Top = 360
Width = 1095
End
Begin VB.Label Label1
Caption = "所用串口(1,2,3,4):"
Height = 270
Left = 240
TabIndex = 1
Top = 360
Width = 2295
End
End
End
Attribute VB_Name = "frmSetting"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cmdCancel_Click()
frmSetting.Hide
Unload frmSetting
End Sub
Private Sub cmdOK_Click()
On Error GoTo SettingError
intPort = Val(frmSetting.txtPort.Text)
intTime = Val(frmSetting.txtTime.Text)
strSet = frmSetting.txtSetting.Text
If Not frmMain.ctrMSComm.PortOpen Then '打开串行口,准备发送
frmMain.ctrMSComm.CommPort = intPort '设置串行口号
frmMain.ctrMSComm.Settings = strSet '设置波特率等
frmMain.ctrMSComm.PortOpen = True '打开串行口
End If
If Not blnAutoSendFlag And Not blnReceiveFlag Then
frmMain.ctrMSComm.PortOpen = False '关闭串行口
End If
frmSetting.Hide
Unload frmSetting
Exit Sub
SettingError:
intPort = 2
intTime = 1000
strSet = "9600,n,1"
frmSetting.Show
frmSetting.txtPort.Text = str(intPort)
frmSetting.txtSetting.Text = strSet
frmSetting.txtTime.Text = str(intTime)
Select Case ErrNumber
Case 380
MsgBox ("属性设置错误")
Case 8002
MsgBox ("错误的串口号")
End Select
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -