📄 commset.frm
字号:
Caption = "偶校验"
BeginProperty Font
Name = "MS Sans Serif"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 240
Index = 1
Left = 1320
TabIndex = 11
Top = 600
Width = 975
End
Begin VB.OptionButton OptionParity
Caption = "无校验"
BeginProperty Font
Name = "MS Sans Serif"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 225
Index = 0
Left = 240
TabIndex = 10
Top = 360
Value = -1 'True
Width = 975
End
End
Begin VB.Frame FrameBaud
Caption = "波特率"
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 975
Left = 120
TabIndex = 2
Top = 1800
Width = 2535
Begin VB.OptionButton OptionBaud
Caption = "19.2K"
BeginProperty Font
Name = "MS Sans Serif"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Index = 3
Left = 1440
TabIndex = 9
Top = 600
Width = 975
End
Begin VB.OptionButton OptionBaud
Caption = "9600"
BeginProperty Font
Name = "MS Sans Serif"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Index = 2
Left = 360
TabIndex = 8
Top = 600
Value = -1 'True
Width = 975
End
Begin VB.OptionButton OptionBaud
Caption = "4800"
BeginProperty Font
Name = "MS Sans Serif"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Index = 1
Left = 1440
TabIndex = 7
Top = 360
Width = 855
End
Begin VB.OptionButton OptionBaud
Caption = "2400"
BeginProperty Font
Name = "MS Sans Serif"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Index = 0
Left = 360
TabIndex = 6
Top = 360
Width = 1095
End
End
Begin VB.ComboBox cmbPort
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 420
ItemData = "CommSet.frx":0000
Left = 1200
List = "CommSet.frx":001C
Style = 2 'Dropdown List
TabIndex = 0
Top = 1200
Width = 1455
End
Begin VB.Label Label1
Caption = "串口名"
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Index = 1
Left = 120
TabIndex = 1
Top = 1320
Width = 855
End
End
Attribute VB_Name = "CommSet"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Port(1 To 8) As Integer
Private Baud(1 To 8), parity(1 To 8), DataBit(1 To 8), StopBit(1 To 8) As String
Private Which As Integer
Private m_bOk As Boolean
Public Function IsOk() As Boolean
IsOk = m_bOk
End Function
Public Sub SendCommSetting(ByVal i As Integer, ByVal iPort As Integer, ByVal sBaud As String, ByVal sParity As String, ByVal sDataBit As String, ByVal sStopBit As String)
Port(i) = iPort
parity(i) = sParity
Baud(i) = sBaud
DataBit(i) = sDataBit
StopBit(i) = sStopBit
End Sub
Private Sub cmdCancle_Click()
Unload Me
End Sub
Private Sub cmdOk_Click()
If Port(1) = Port(2) And Port(2) = Port(3) And Port(3) = Port(4) Then
MsgBox "Gps和110串口不可以相同"
Exit Sub
End If
Ini_SaveCommSetting "comm1", Port(1), Baud(1), parity(1), DataBit(1), StopBit(1)
Ini_SaveCommSetting "comm2", Port(2), Baud(2), parity(2), DataBit(2), StopBit(2)
Ini_SaveCommSetting "comm3", Port(3), Baud(3), parity(3), DataBit(3), StopBit(3)
Ini_SaveCommSetting "comm4", Port(4), Baud(4), parity(4), DataBit(4), StopBit(4)
Ini_SaveCommSetting "comm5", Port(5), Baud(5), parity(5), DataBit(5), StopBit(5)
Ini_SaveCommSetting "comm6", Port(6), Baud(6), parity(6), DataBit(6), StopBit(6)
Ini_SaveCommSetting "comm7", Port(7), Baud(7), parity(7), DataBit(7), StopBit(7)
Ini_SaveCommSetting "comm8", Port(8), Baud(8), parity(8), DataBit(8), StopBit(8)
m_bOk = True
Unload Me
End Sub
Private Sub Form_Load()
m_bOk = False
Which = 1
SetCommSetting Port(1), Baud(1), parity(1), DataBit(1), StopBit(1)
OptionFunc(1).Value = True
End Sub
Private Sub OptionFunc_Click(Index As Integer)
Which = Index
SetCommSetting Port(Index), Baud(Index), parity(Index), DataBit(Index), StopBit(Index)
End Sub
Private Sub SetCommSetting(ByVal Port As Integer, _
ByVal Baud As String, ByVal parity As String, _
ByVal DataBit As String, ByVal StopBit As String)
Select Case Port
Case 1
cmbPort.ListIndex = 0
Case 2
cmbPort.ListIndex = 1
Case 3
cmbPort.ListIndex = 2
Case 4
cmbPort.ListIndex = 3
Case 5
cmbPort.ListIndex = 4
Case 6
cmbPort.ListIndex = 5
Case 7
cmbPort.ListIndex = 6
Case 8
cmbPort.ListIndex = 7
End Select
Select Case Baud
Case "2400"
OptionBaud(0).Value = True
Case "4800"
OptionBaud(1).Value = True
Case "9600"
OptionBaud(2).Value = True
Case "19200"
OptionBaud(3).Value = True
End Select
Select Case parity
Case "N"
OptionParity(0).Value = True
Case "O"
OptionParity(1).Value = True
Case "E"
OptionParity(2).Value = True
End Select
Select Case DataBit
Case "5"
OptionDataBits(0).Value = True
Case "6"
OptionDataBits(1).Value = True
Case "7"
OptionDataBits(2).Value = True
Case "8"
OptionDataBits(3).Value = True
End Select
Select Case StopBit
Case "1"
OptionStopBits(0).Value = True
Case "1.5"
OptionStopBits(1).Value = True
Case "2"
OptionStopBits(2).Value = True
End Select
End Sub
Private Sub cmbPort_Click()
Port(Which) = cmbPort.ItemData(cmbPort.ListIndex)
End Sub
Private Sub OptionBaud_Click(Index As Integer)
If OptionBaud(0).Value Then
Baud(Which) = "2400"
End If
If OptionBaud(1).Value Then
Baud(Which) = "4800"
End If
If OptionBaud(2).Value Then
Baud(Which) = "9600"
End If
If OptionBaud(3).Value Then
Baud(Which) = "19200"
End If
End Sub
Private Sub OptionParity_Click(Index As Integer)
If OptionParity(0).Value Then
parity(Which) = "N"
End If
If OptionParity(1).Value Then
parity(Which) = "O"
End If
If OptionParity(2).Value Then
parity(Which) = "E"
End If
End Sub
Private Sub OptionDataBits_Click(Index As Integer)
If OptionDataBits(0).Value Then
DataBit(Which) = "5"
End If
If OptionDataBits(1).Value Then
DataBit(Which) = "6"
End If
If OptionDataBits(2).Value Then
DataBit(Which) = "7"
End If
If OptionDataBits(3).Value Then
DataBit(Which) = "8"
End If
End Sub
Private Sub OptionStopBits_Click(Index As Integer)
If OptionStopBits(0).Value Then
StopBit(Which) = "1"
End If
If OptionStopBits(1).Value Then
StopBit(Which) = "1.5"
End If
If OptionStopBits(2).Value Then
StopBit(Which) = "2"
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -