?? frmsetup.frm
字號:
VERSION 5.00
Begin VB.Form frmSetup
BorderStyle = 1 'Fixed Single
Caption = "CommPort Setup"
ClientHeight = 2940
ClientLeft = 45
ClientTop = 330
ClientWidth = 3990
Icon = "frmSetup.frx":0000
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
ScaleHeight = 2940
ScaleWidth = 3990
StartUpPosition = 1 'CenterOwner
Begin VB.Frame Frame1
Caption = "Remote Host"
Height = 975
Left = 1560
TabIndex = 14
Top = 1320
Width = 2250
Begin VB.TextBox txtPort
Height = 285
Left = 600
TabIndex = 18
Top = 600
Width = 1095
End
Begin VB.TextBox txtIP
Height = 285
Left = 600
TabIndex = 16
Top = 240
Width = 1575
End
Begin VB.Label Label3
Alignment = 2 'Center
Caption = "Port"
Height = 255
Left = 120
TabIndex = 17
Top = 600
Width = 375
End
Begin VB.Label Label1
Alignment = 2 'Center
Caption = "IP"
Height = 255
Left = 240
TabIndex = 15
Top = 240
Width = 255
End
End
Begin VB.TextBox txtInterval
Height = 285
Left = 720
MaxLength = 2
TabIndex = 11
ToolTipText = "1-5 "
Top = 1920
Width = 495
End
Begin VB.Frame Frame4
Caption = "EM"
Height = 1335
Left = 120
TabIndex = 3
Top = 240
Width = 1215
Begin VB.OptionButton optEndMark
Caption = "CRLF"
Height = 195
Index = 2
Left = 120
TabIndex = 6
Top = 960
Width = 735
End
Begin VB.OptionButton optEndMark
Caption = "CR"
Height = 255
Index = 1
Left = 120
TabIndex = 5
Top = 600
Width = 735
End
Begin VB.OptionButton optEndMark
Caption = "None"
Height = 195
Index = 0
Left = 120
TabIndex = 4
Top = 240
Value = -1 'True
Width = 735
End
End
Begin VB.CommandButton cmdOK
Caption = "OK"
Default = -1 'True
Height = 375
Left = 3120
MaskColor = &H00000000&
TabIndex = 0
Top = 2400
Width = 720
End
Begin VB.CommandButton cmdCancel
Caption = "Cancel"
Height = 375
Left = 2280
TabIndex = 1
Top = 2400
Width = 720
End
Begin VB.ComboBox cboGroupParity
Height = 315
ItemData = "frmSetup.frx":0442
Left = 1800
List = "frmSetup.frx":0444
TabIndex = 2
Text = "None"
Top = 720
Width = 855
End
Begin VB.Frame Frame6
Caption = "Protocols"
Height = 975
Left = 1560
TabIndex = 7
Top = 240
Width = 2250
Begin VB.TextBox txtADDress
Height = 285
Left = 1200
MaxLength = 2
TabIndex = 10
Text = "01"
ToolTipText = "01-FF"
Top = 480
Width = 855
End
Begin VB.Label Label6
Caption = "ADDress"
Height = 255
Left = 1200
TabIndex = 9
Top = 240
Width = 735
End
Begin VB.Label Label2
Caption = "BCC"
Height = 255
Left = 240
TabIndex = 8
Top = 240
Width = 615
End
End
Begin VB.Label Label8
Caption = "S"
Height = 255
Left = 1200
TabIndex = 13
Top = 2040
Width = 255
End
Begin VB.Label Label7
Caption = "Interval"
Height = 255
Left = 120
TabIndex = 12
Top = 2040
Width = 615
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 Sub LoadPropertySettings()
' Load Block Parities
cboGroupParity.AddItem "None"
cboGroupParity.AddItem "Xor"
cboGroupParity.AddItem "Add"
cboGroupParity.ListIndex = nBlockParity
' Set Default Settings
With frmMain.tcpWinsock
txtIP.Text = .RemoteHost
txtPort.Text = .RemotePort
End With
End Sub
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdOK_Click()
Dim lInterval As Long
Dim nADDress As Integer
Dim bTimer As Boolean
On Error Resume Next
With frmMain.tcpWinsock
.Close
.RemoteHost = txtIP.Text
.RemotePort = Val(txtPort.Text)
RemoteHost = txtIP.Text
RemotePort = .RemotePort
End With
If Err.Number <> 0 Then
MsgBox Error$, vbCritical + vbOKOnly
Exit Sub
End If
frmMain.timerComm.Interval = 500
Select Case cboGroupParity.Text
Case "None"
nBlockParity = CHK_NONE
Case "Xor"
nBlockParity = CHK_XOR
Case "Add"
nBlockParity = CHK_ADD
End Select
lInterval = Val(txtInterval.Text)
If lInterval <= 0 Or lInterval > 5 Then lInterval = 3
bTimer = frmMain.timerIn.Enabled
If bTimer = True Then frmMain.timerIn.Enabled = False
frmMain.timerIn.Interval = lInterval * 1000
frmMain.timerIn.Enabled = bTimer
nADDress = TwoHexCharsToByte(txtADDress.Text)
If nADDress < 1 Or nADDress > 255 Then nADDress = 1
strADDress = ByteToTwoHexChars(nADDress)
SaveSetting App.Title, "Properties", "RemoteHost", txtIP.Text
SaveSetting App.Title, "Properties", "RemotePort", txtPort.Text
SaveSetting App.Title, "Properties", "EndMark", Str(nEndMark)
SaveSetting App.Title, "Properties", "BlockParity", Str(nBlockParity)
SaveSetting App.Title, "Properties", "lInterval", lInterval
SaveSetting App.Title, "Properties", "ADDress", strADDress
bSwitch = True
ERROR_MARK:
frmMain.SetTcpStatus
Unload Me
End Sub
Private Sub Form_Load()
SetWindowPos frmSetup.hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
' Load current property settings
LoadPropertySettings
Select Case nEndMark
Case ADD_NONE
optEndMark(0).Value = True
Case ADD_CR
optEndMark(1).Value = True
Case ADD_CRLF
optEndMark(2).Value = True
End Select
txtInterval.Text = frmMain.timerIn.Interval \ 1000
txtADDress.Text = strADDress
nReplyLen = 6 'Bytes
End Sub
Private Sub Form_Unload(Cancel As Integer)
If nBlockParity = CHK_NONE Then
nReplyLen = nReplyLen - 1
End If
Select Case nEndMark
Case ADD_NONE
nReplyLen = nReplyLen - 2
Case ADD_CR
nReplyLen = nReplyLen - 1
End Select
End Sub
Private Sub optEndMark_Click(Index As Integer)
nEndMark = Index
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -