?? frmsetup.frm
字號:
Height = 615
Left = 2640
TabIndex = 0
Top = 120
Width = 1650
Begin VB.CheckBox chkDTR
Caption = "DTR"
Height = 255
Left = 120
TabIndex = 2
Top = 240
Width = 735
End
Begin VB.CheckBox chkRTS
Caption = "RTS"
Height = 255
Left = 840
TabIndex = 1
Top = 240
Width = 735
End
End
Begin VB.Frame Frame6
Caption = "Remote"
Height = 1215
Left = 4440
TabIndex = 34
Top = 1680
Width = 1215
End
Begin VB.Label Label2
Caption = "Local Port"
Height = 255
Left = 4560
TabIndex = 30
Top = 1080
Width = 735
End
Begin VB.Label Label1
Caption = "Port:"
Height = 315
Left = 270
TabIndex = 23
Top = 240
Width = 495
End
End
Attribute VB_Name = "frmSetup"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private iFlow As Integer
Private iDisplayMode As Integer
Private iWorkMode As Integer
Sub LoadPropertySettings()
Dim I As Integer
Dim Settings As String
Dim Offset As Integer
' Load Port Settings
For I = 1 To 16
cboPort.AddItem "Com" & Trim$(Str$(I))
Next I
' 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"
' Load Data Bit Settings
cboDataBits.AddItem "4"
cboDataBits.AddItem "5"
cboDataBits.AddItem "6"
cboDataBits.AddItem "7"
cboDataBits.AddItem "8"
' Load Parity Settings
cboParity.AddItem "Even"
cboParity.AddItem "Odd"
cboParity.AddItem "None"
cboParity.AddItem "Mark"
cboParity.AddItem "Space"
' Load Stop Bit Settings
cboStopBits.AddItem "1"
cboStopBits.AddItem "1.5"
cboStopBits.AddItem "2"
' Set Default Settings
Settings = frmMain.MSComm1.Settings
' In all cases the right most part of Settings will be 1 character
' except when there are 1.5 stop bits.
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 "o"
cboParity.ListIndex = 1
Case "n"
cboParity.ListIndex = 2
Case "m"
cboParity.ListIndex = 3
Case "s"
cboParity.ListIndex = 4
End Select
cboDataBits.Text = Mid$(Settings, Len(Settings) - 2 - Offset, 1)
cboStopBits.Text = Right$(Settings, 1 + Offset)
cboPort.ListIndex = frmMain.MSComm1.CommPort - 1
optFlow(frmMain.MSComm1.Handshaking).Value = True
chkDTR.Value = IIf(frmMain.MSComm1.DTREnable = True, 1, 0)
chkRTS.Value = IIf(frmMain.MSComm1.RTSEnable = True, 1, 0)
End Sub
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdOK_Click()
Dim nOldPort As Integer
Dim nNewPort As Integer
Dim bReOpen As Boolean
Dim strTmp As String
On Error Resume Next
nOldPort = frmMain.MSComm1.CommPort
nNewPort = cboPort.ListIndex + 1
If nNewPort <> nOldPort Then ' If the port number changes, close the old port.
If frmMain.MSComm1.PortOpen Then
frmMain.MSComm1.PortOpen = False
bReOpen = True
End If
frmMain.MSComm1.CommPort = nNewPort ' Set the new port number.
If Err = 0 Then
If bReOpen Then
Call frmMain.cmdOpen_Click
End If
End If
If Err Then
MsgBox Error$, vbExclamation + vbOKOnly
frmMain.MSComm1.CommPort = nOldPort
Exit Sub
End If
End If
frmMain.MSComm1.Settings = Trim$(cboSpeed.Text) & "," & Left$(cboParity.Text, 1) _
& "," & Trim$(cboDataBits.Text) & "," & Trim$(cboStopBits.Text)
If Err Then
MsgBox Error$, vbExclamation + vbOKOnly
Exit Sub
End If
frmMain.MSComm1.DTREnable = IIf(chkDTR.Value = 1, True, False)
frmMain.MSComm1.RTSEnable = IIf(chkRTS.Value = 1, True, False)
frmMain.MSComm1.Handshaking = iFlow
If iFlow >= 2 Then
frmMain.MSComm1.RTSEnable = True
End If
If Err Then
MsgBox Error$, vbExclamation + vbOKOnly
Exit Sub
End If
nLocalPort = Val(txtLocalPort.Text)
nRemotePort = Val(txtRemotePort.Text)
strRemoteHost = txtRemoteHost.Text
nWorkMode = iWorkMode
nDisplayMode = iDisplayMode
If nWorkMode = 0 Then
frmMain.cmdConnect.Caption = "Connect"
Else
frmMain.cmdConnect.Caption = "Listen"
End If
Dim Settings As String
Settings = frmMain.MSComm1.Settings
If bReOpen = True Then
ResultString = ResultString + GetTimeStamp(0) + "Current serial port settings: " _
+ "COM" + Trim(Str(frmMain.MSComm1.CommPort)) + "; " + Settings + "; " + _
IIf(frmMain.MSComm1.PortOpen = True, "Open", "Close")
Call DisplayString(frmMain.txtResult, ResultString)
End If
SaveSetting App.Title, "Properties", "Settings", frmMain.MSComm1.Settings
SaveSetting App.Title, "Properties", "CommPort", frmMain.MSComm1.CommPort
SaveSetting App.Title, "Properties", "Handshaking", frmMain.MSComm1.Handshaking
SaveSetting App.Title, "Properties", "DisplayMode", Str(nDisplayMode)
SaveSetting App.Title, "Properties", "WorkMode", Str(nWorkMode)
SaveSetting App.Title, "Properties", "LocalPort", Str(nLocalPort)
SaveSetting App.Title, "Properties", "RemotePort", Str(nRemotePort)
SaveSetting App.Title, "Properties", "RemoteHost", strRemoteHost
Unload Me
End Sub
Private Sub Form_Load()
' Load current property settings
LoadPropertySettings
If frmMain.MSComm1.InputMode = comInputModeBinary Then
optMode(1).Value = True
Else
optMode(0).Value = True
End If
If nDisplayMode = 0 Then
optDisplayMode(0).Value = True
Else
optDisplayMode(1).Value = True
End If
If nWorkMode = 0 Then
optWorkMode(0).Value = True
Else
optWorkMode(1).Value = True
End If
txtLocalPort.Text = nLocalPort
txtRemotePort.Text = nRemotePort
txtRemoteHost.Text = strRemoteHost
End Sub
Private Sub optDisplayMode_Click(Index As Integer)
iDisplayMode = Index
End Sub
Private Sub optMode_Click(Index As Integer)
If Index = 1 Then
frmMain.MSComm1.InputMode = comInputModeBinary
Else
frmMain.MSComm1.InputMode = comInputModeText
End If
End Sub
Private Sub optFlow_Click(Index As Integer)
iFlow = Index
End Sub
Private Sub optWorkMode_Click(Index As Integer)
iWorkMode = Index
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -