?? frmcommprops.frm
字號:
Height = 255
Index = 0
Left = 180
MaskColor = &H00000000&
TabIndex = 5
Top = 315
Width = 855
End
Begin VB.OptionButton optFlow
Caption = "Xon/Xoff"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Index = 1
Left = 180
MaskColor = &H00000000&
TabIndex = 6
Top = 645
Width = 1095
End
Begin VB.OptionButton optFlow
Caption = "RTS"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Index = 2
Left = 180
MaskColor = &H00000000&
TabIndex = 7
Top = 990
Value = -1 'True
Width = 735
End
Begin VB.OptionButton optFlow
Caption = "Xon/RTS"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Index = 3
Left = 180
MaskColor = &H00000000&
TabIndex = 8
Top = 1320
Width = 1155
End
End
Begin VB.Label Label1
Caption = "串口:"
BeginProperty Font
Name = "宋體"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 312
Left = 216
TabIndex = 14
Top = 180
Width = 612
End
End
Begin MSComctlLib.TabStrip tabSettings
Height = 3975
Left = 120
TabIndex = 19
Top = 120
Width = 4815
_ExtentX = 8493
_ExtentY = 7011
_Version = 393216
BeginProperty Tabs {1EFB6598-857C-11D1-B16A-00C0F0283628}
NumTabs = 1
BeginProperty Tab1 {1EFB659A-857C-11D1-B16A-00C0F0283628}
Caption = "屬性"
ImageVarType = 2
EndProperty
EndProperty
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋體"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
End
Attribute VB_Name = "frmCommProperties"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Public frmComm As Form
' Load Port Settings to Choose
Public Sub LoadPropertySettings()
Dim i As Integer, Offset As Integer
For i = 1 To 16
cboPort.AddItem "Com" & Trim$(Str$(i))
Next i
cboPort.ListIndex = 1
' Load Speed Settings
cboSpeed.AddItem "110"
cboSpeed.AddItem "300"
cboSpeed.AddItem "600"
cboSpeed.AddItem "1200"
cboSpeed.AddItem "2400"
cboSpeed.AddItem "4800"
cboSpeed.AddItem "9600"
cboSpeed.AddItem "14400"
cboSpeed.AddItem "19200"
cboSpeed.AddItem "28800"
cboSpeed.AddItem "38400"
cboSpeed.AddItem "56000"
cboSpeed.AddItem "57600"
cboSpeed.AddItem "115200"
cboSpeed.AddItem "128000"
cboSpeed.AddItem "256000"
cboSpeed.AddItem "384000"
cboSpeed.ListIndex = 11
' Load Data Bit Settings
cboDataBits.AddItem "4"
cboDataBits.AddItem "5"
cboDataBits.AddItem "6"
cboDataBits.AddItem "7"
cboDataBits.AddItem "8"
cboDataBits.ListIndex = 4
' Load Parity Settings
cboParity.AddItem "Even"
cboParity.AddItem "Odd"
cboParity.AddItem "None"
cboParity.AddItem "Mark"
cboParity.AddItem "Space"
cboParity.ListIndex = 2
' Load Stop Bit Settings
cboStopBits.AddItem "1"
cboStopBits.AddItem "1.5"
cboStopBits.AddItem "2"
cboStopBits.ListIndex = 0
' Set Default Settings
Dim Settings As String
Settings = GetSetting("通訊端口設(shè)置", "Properties", "Settings", "")
If Settings <> "" Then '已保存到過注冊表
Else
Settings = frmComm.MSComm1.Settings '取默認(rèn)配置
End If
If Settings <> "" Then '找到可用Settings
If InStr(Settings, ".") > 0 Then
Offset = 2
Else
Offset = 0
End If
cboSpeed.Text = Left$(Settings, Len(Settings) - 6 - Offset)
Select Case Mid$(Settings, Len(Settings) - 4 - Offset, 1)
Case "e"
cboParity.ListIndex = 0
Case "m"
cboParity.ListIndex = 1
Case "n"
cboParity.ListIndex = 2
Case "o"
cboParity.ListIndex = 3
Case "s"
cboParity.ListIndex = 4
End Select
cboDataBits.Text = Mid$(Settings, Len(Settings) - 2 - Offset, 1)
cboStopBits.Text = Mid(Settings, Len(Settings) - Offset)
cboPort.ListIndex = frmComm.MSComm1.commPort - 1
optFlow(frmComm.MSComm1.Handshaking).Value = True
End If
End Sub
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdOK_Click()
Dim OldPort As Integer, NewPort As Integer, ReOpen As Boolean
Dim t As Integer
On Error Resume Next
OldPort = frmComm.MSComm1.commPort
NewPort = cboPort.ListIndex + 1
If NewPort <> OldPort Then ' If the port number changes, close the old port.
If frmComm.MSComm1.PortOpen = True Then
frmComm.MSComm1.PortOpen = False
ReOpen = True
End If
' Set the new port number.
frmComm.MSComm1.commPort = NewPort
If Err = 0 Then
If ReOpen Then
frmComm.MSComm1.PortOpen = True
End If
End If
If Err Then
MsgBox Error$, 48
frmComm.MSComm1.commPort = OldPort
Exit Sub
End If
End If
frmComm.MSComm1.Settings = Trim$(cboSpeed.Text) & "," & _
Left$(cboParity.Text, 1) & "," & _
Trim$(cboDataBits.Text) & "," & _
Trim$(cboStopBits.Text)
If Err Then
MsgBox Error$, 48
Exit Sub
End If
Dim i As Integer
For i = 0 To 3
If optFlow(i).Value = True Then
frmComm.MSComm1.Handshaking = i
Exit For
End If
Next i
If Err Then
MsgBox Error$, 48
Exit Sub
End If
SaveSetting "通訊端口設(shè)置", "Properties", "Settings", frmComm.MSComm1.Settings
SaveSetting "通訊端口設(shè)置", "Properties", "CommPort", frmComm.MSComm1.commPort
SaveSetting "通訊端口設(shè)置", "Properties", "Handshaking", frmComm.MSComm1.Handshaking
frmComm.bCommSetOK = True
Unload Me
End Sub
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -