📄 dlgsetcomm.frm
字号:
VERSION 5.00
Begin VB.Form dlgSetComm
Caption = "Form1"
ClientHeight = 3195
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3195
ScaleWidth = 4680
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton cmdOk
Caption = "确定"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 372
Left = 795
TabIndex = 6
Top = 2520
Width = 1215
End
Begin VB.ComboBox cmbBoundary
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 330
ItemData = "dlgSetComm.frx":0000
Left = 1200
List = "dlgSetComm.frx":0037
Style = 2 'Dropdown List
TabIndex = 5
Top = 840
Width = 1212
End
Begin VB.ComboBox cmbComport
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 330
ItemData = "dlgSetComm.frx":00A9
Left = 1200
List = "dlgSetComm.frx":00C5
Style = 2 'Dropdown List
TabIndex = 4
Top = 240
Width = 612
End
Begin VB.ComboBox cmbDatalen
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 330
ItemData = "dlgSetComm.frx":00E1
Left = 3480
List = "dlgSetComm.frx":00F4
Style = 2 'Dropdown List
TabIndex = 3
Top = 840
Width = 612
End
Begin VB.CommandButton cmdCancel
Caption = "取消"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 2715
TabIndex = 2
Top = 2520
Width = 1215
End
Begin VB.ComboBox cmbStopbit
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 330
ItemData = "dlgSetComm.frx":0107
Left = 3480
List = "dlgSetComm.frx":0114
Style = 2 'Dropdown List
TabIndex = 1
Top = 1440
Width = 732
End
Begin VB.ComboBox cmbParity
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 330
ItemData = "dlgSetComm.frx":0123
Left = 1200
List = "dlgSetComm.frx":0136
Style = 2 'Dropdown List
TabIndex = 0
Top = 1440
Width = 1212
End
Begin VB.Label Label1
Caption = "波特率"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 285
Left = 480
TabIndex = 11
Top = 840
Width = 735
End
Begin VB.Label Label2
Caption = "通讯口"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 285
Left = 480
TabIndex = 10
Top = 240
Width = 735
End
Begin VB.Label Label3
Caption = "字长"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 285
Left = 2640
TabIndex = 9
Top = 840
Width = 495
End
Begin VB.Label Label4
Caption = "停止位"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 285
Left = 2640
TabIndex = 8
Top = 1440
Width = 735
End
Begin VB.Label Label5
Caption = "校验"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 285
Left = 480
TabIndex = 7
Top = 1440
Width = 495
End
End
Attribute VB_Name = "dlgSetComm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim Bound, Datalen, Stopbit As Single
Dim para, ParaList As String
Private Sub cmdCancel_Click()
Me.Hide
End Sub
Private Sub cmdOK_Click()
On Error GoTo ErrHandle
Frmmian.MSComm1.CommPort = cmbComport.Text
Frmmian.MSComm1.Settings = _
cmbBoundary.Text + "," + _
Mid(ParaList, cmbParity.ListIndex + 1, 1) + "," + _
cmbDatalen.Text + "," + cmbStopbit.Text
Bound = cmbBoundary.Text
para = Mid(ParaList, cmbParity.ListIndex + 1, 1)
Datalen = cmbDatalen.Text
Stopbit = cmbStopbit.Text
SetMessage
Me.Hide
Exit Sub
ErrHandle:
MsgBox "错误的设置!", vbInformation, "端口设置错误"
End Sub
Private Sub Form_activate()
cmbComport.Text = Frmmian.MSComm1.CommPort
cmbBoundary.Text = Bound
cmbParity.ListIndex = InStr(1, ParaList, UCase(para)) - 1
cmbDatalen.Text = Datalen
cmbStopbit.Text = Stopbit
End Sub
Private Sub Form_Load()
Bound = 9600
para = "n"
Datalen = 8
Stopbit = 1
ParaList = "EOMSN"
Form_activate
SetMessage
End Sub
Private Sub SetMessage()
Frmmian.lblSetting.Caption = "端口号:" + cmbComport.Text + _
Chr(13) + Chr(10) + _
"波特率:" + cmbBoundary.Text + _
",校验方式:" + cmbParity.Text + _
"," + cmbDatalen.Text + "位字长 ," + _
cmbStopbit + "位停止位"
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -