📄 frminitport.frm
字号:
VERSION 5.00
Begin VB.Form frmInitPort
BorderStyle = 3 'Fixed Dialog
Caption = "串口配置"
ClientHeight = 5325
ClientLeft = 45
ClientTop = 330
ClientWidth = 7785
ControlBox = 0 'False
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 5325
ScaleWidth = 7785
ShowInTaskbar = 0 'False
StartUpPosition = 2 '屏幕中心
Begin VB.Frame Frame2
Height = 2775
Left = 360
TabIndex = 3
Top = 480
Width = 6135
Begin VB.ComboBox ComboStop
Height = 300
Left = 2280
TabIndex = 12
Top = 2160
Width = 1815
End
Begin VB.ComboBox ComboData
Height = 300
Left = 2280
TabIndex = 10
Top = 1200
Width = 1815
End
Begin VB.ComboBox ComboSerial
Height = 300
Left = 2280
TabIndex = 8
Top = 240
Width = 1815
End
Begin VB.ComboBox cmbParity
Height = 300
Left = 2280
TabIndex = 5
Top = 1680
Width = 1815
End
Begin VB.ComboBox cmbBaudRate
Height = 300
Left = 2280
TabIndex = 4
Top = 720
Width = 1815
End
Begin VB.Label LabelStop
Caption = "停止位"
Height = 255
Left = 840
TabIndex = 13
Top = 2160
Width = 615
End
Begin VB.Label LabelData
Caption = "数据位"
Height = 255
Left = 840
TabIndex = 11
Top = 1200
Width = 615
End
Begin VB.Label LabelSerial
Caption = "串口号"
Height = 255
Left = 840
TabIndex = 9
Top = 240
Width = 735
End
Begin VB.Label lblParity
Caption = "校验位"
Height = 255
Left = 840
TabIndex = 7
Top = 1680
Width = 855
End
Begin VB.Label lblBaudRate
Caption = "波特率"
Height = 255
Left = 840
TabIndex = 6
Top = 720
Width = 615
End
End
Begin VB.CommandButton cmdCancel
Caption = "取消"
Height = 375
Left = 4080
TabIndex = 1
Top = 3480
Width = 1215
End
Begin VB.CommandButton cmdOK
Caption = "确定"
Height = 375
Left = 960
TabIndex = 0
Top = 3480
Width = 1215
End
Begin VB.Frame Frame1
Caption = "通信设置"
Height = 3975
Left = 120
TabIndex = 2
Top = 120
Width = 6975
End
End
Attribute VB_Name = "frmInitPort"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim BaudRate As String
Dim Parity As String
Dim Data As String
Dim Serial As String
Dim StopBit As String
Private Sub cmbBaudRate_Scroll()
BaudRate = cmbBaudRate.Text
End Sub
Private Sub cmbParity_Scroll()
Parity = cmbParity.Text
End Sub
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdOK_Click()
BaudRate = cmbBaudRate.Text
Parity = cmbParity.Text
' Dim port As Integer
' If (frmZong.Comm.CommPort = 1) Then
' port = 0
' End If
' port = frmZong.Comm.CommPort
' frmZong.Comm.PortOpen = False
'
' If optCom1.Value = True Then
' If (frmZong.Comm.CommPort = 1) = True Then
' frmZong.Comm.PortOpen = True
' End If
' End If
' If optCom2.Value = True Then
' If (frmZong.Comm.CommPort = 2) = True Then
' frmZong.Comm.PortOpen = True
' End If
' End If
Data = ComboData.Text
Serial = ComboSerial.Text
StopBit = ComboStop.Text
If Serial = "COM1" Then
frmZong.Comm.PortOpen = False
frmZong.Comm.CommPort = 1
frmZong.Comm.PortOpen = True
End If
If Serial = "COM2" Then
frmZong.Comm.PortOpen = False
frmZong.Comm.CommPort = 2
frmZong.Comm.PortOpen = True
End If
If Serial = "COM3" Then
frmZong.Comm.PortOpen = False
frmZong.Comm.CommPort = 3
frmZong.Comm.PortOpen = True
End If
If Serial = "COM4" Then
frmZong.Comm.PortOpen = False
frmZong.Comm.CommPort = 4
frmZong.Comm.PortOpen = True
End If
' frmZong.Comm.PortOpen = False
frmZong.Comm.Settings = BaudRate + "," + Parity + "," + Data + "," + StopBit
' frmZong.Comm.Settings = "9600" + "," + "N" + ",8" + ",1"
' frmZong.Comm.Settings = "9600,N,8,1"
' frmZong.Comm.PortOpen = True
frmInitPort.Hide
End Sub
Private Sub ComboData_Change()
Data = ComboData.Text
End Sub
Private Sub ComboSerial_Change()
Serial = ComboSerial.Text
End Sub
Private Sub ComboStop_Change()
StopBit = ComboStop.Text
End Sub
Private Sub Form_Load()
cmbBaudRate.AddItem (1200)
cmbBaudRate.AddItem (2400)
cmbBaudRate.AddItem (4800)
cmbBaudRate.AddItem (9600)
cmbBaudRate.AddItem (14400)
cmbBaudRate.AddItem (19200)
ComboSerial.AddItem ("COM1")
ComboSerial.AddItem ("COM2")
ComboSerial.AddItem ("COM3")
ComboSerial.AddItem ("COM4")
ComboData.AddItem (8)
ComboData.AddItem (7)
ComboData.AddItem (6)
ComboData.AddItem (5)
ComboData.AddItem (4)
ComboStop.AddItem (1)
ComboStop.AddItem (1.5)
ComboStop.AddItem (2)
'ComboStop.AddItem (4)
cmbParity.AddItem ("O")
cmbParity.AddItem ("E")
cmbParity.AddItem ("None")
cmbParity.AddItem ("M")
cmbParity.AddItem ("N")
cmbParity.AddItem ("S")
ComboSerial.Text = "COM1"
cmbBaudRate.Text = 2400
ComboData.Text = 8
ComboStop.Text = 1
cmbParity.Text = "O"
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -