📄 form2.frm
字号:
VERSION 5.00
Begin VB.Form Form2
AutoRedraw = -1 'True
Caption = "Port Setting"
ClientHeight = 510
ClientLeft = 165
ClientTop = 495
ClientWidth = 2850
Icon = "Form2.frx":0000
LinkTopic = "Form2"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 510
ScaleWidth = 2850
StartUpPosition = 3 'Windows Default
Begin VB.ComboBox COMt
Height = 315
ItemData = "Form2.frx":0442
Left = 720
List = "Form2.frx":045B
TabIndex = 18
Text = "4 - COM7"
Top = 120
Width = 1215
End
Begin VB.CommandButton Command4
Caption = "Apply"
Height = 375
Left = 7680
TabIndex = 16
Top = 5400
Width = 735
End
Begin VB.CommandButton Command3
Caption = "Cancel"
Height = 375
Left = 6480
TabIndex = 15
Top = 5400
Width = 975
End
Begin VB.CommandButton Command2
Caption = "OK"
Height = 375
Left = 2040
TabIndex = 14
Top = 120
Width = 735
End
Begin VB.CommandButton Command1
Caption = "Restore Defaults"
BeginProperty Font
Name = "Tahoma"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 8640
TabIndex = 2
Top = 5280
Width = 855
End
Begin VB.PictureBox SSFrame1
Height = 3735
Left = 5640
ScaleHeight = 3675
ScaleWidth = 3975
TabIndex = 1
Top = 1350
Visible = 0 'False
Width = 4035
Begin VB.ComboBox Flowcontrol
Height = 315
ItemData = "Form2.frx":04A5
Left = 1440
List = "Form2.frx":04B5
TabIndex = 12
Text = "0 - None"
Top = 3000
Width = 2415
End
Begin VB.ComboBox StopBit
Height = 315
ItemData = "Form2.frx":04FA
Left = 1440
List = "Form2.frx":0504
TabIndex = 10
Text = "1"
Top = 2370
Width = 2415
End
Begin VB.ComboBox Parity
Height = 315
ItemData = "Form2.frx":0513
Left = 1440
List = "Form2.frx":0526
TabIndex = 8
Text = "None"
Top = 1650
Width = 2415
End
Begin VB.ComboBox DataBit
Height = 315
ItemData = "Form2.frx":0548
Left = 1440
List = "Form2.frx":0558
TabIndex = 5
Text = "8"
Top = 1050
Width = 2415
End
Begin VB.ComboBox baud
Height = 315
ItemData = "Form2.frx":056D
Left = 1440
List = "Form2.frx":05A1
TabIndex = 4
Text = "9600 "
Top = 360
Width = 2415
End
Begin VB.Label Label7
Caption = "Flow control:"
Height = 315
Left = 240
TabIndex = 13
Top = 3060
Width = 2415
End
Begin VB.Label Label6
Caption = "Stop bits:"
Height = 315
Left = 240
TabIndex = 11
Top = 2400
Width = 2415
End
Begin VB.Label Label5
Caption = "Parity:"
Height = 315
Left = 240
TabIndex = 9
Top = 1710
Width = 2415
End
Begin VB.Label Label3
Caption = "Data bits:"
Height = 315
Left = 240
TabIndex = 6
Top = 1110
Width = 2415
End
Begin VB.Label Label2
Caption = "Bit persecond:"
Height = 315
Left = 240
TabIndex = 3
Top = 390
Width = 2415
End
End
Begin VB.PictureBox TabStrip1
Height = 5235
Left = 5160
ScaleHeight = 5175
ScaleWidth = 4635
TabIndex = 0
Top = 720
Width = 4695
End
Begin VB.Label Label8
Caption = "PORT"
Height = 315
Left = 120
TabIndex = 17
Top = 180
Width = 735
End
Begin VB.Label Label4
Caption = "Bit persecond:"
Height = 315
Left = 5280
TabIndex = 7
Top = 1080
Width = 1125
End
End
Attribute VB_Name = "Form2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'/*
' * Copyright 2006 by Indigo Manufacturing Inc.
' * All rights reserved. Property of Indigo Manufacturing Inc.
' * September 8, 2006
' */
Option Explicit
Private Sub Command1_Click() 'default
On Error GoTo 1
If (Form1.MSComm1.PortOpen) Then
Form1.MSComm1.PortOpen = False
End If
Form1.MSComm1.CommPort = 1
baud.Text = 9600
DataBit.Text = 8
Parity.Text = "None"
StopBit.Text = 1
Flowcontrol.Text = "0 - comNone"
Exit Sub
1 MsgBox ("The serial port is already in use, Please set to the other port")
End Sub
Public Sub Command2_Click() ' ok
On Error GoTo 1
If (Form1.MSComm1.PortOpen) Then
Form1.MSComm1.PortOpen = False
End If
Form1.MSComm1.CommPort = Mid$(COMt.Text, 1, 1)
Form1.MSComm1.Handshaking = Mid$(Flowcontrol.Text, 1, 1)
Form1.MSComm1.Settings = baud.Text + "," + Mid$(Parity.Text, 1, 1) + "," + DataBit.Text + "," + StopBit.Text
Form1.MSComm1.PortOpen = True
Form1.MSComm1.InBufferCount = 0
Form2.Visible = False
Open App.Path + "\portconfig.ini" For Binary As #1
Dim data As Byte
data = Mid$(Form2.COMt.Text, 1, 1)
Put #1, 1, data
Close #1
Exit Sub
1 MsgBox ("The serial port is already in use, Please set to the other port")
End Sub
Private Sub Command3_Click() ' cancel
Form2.Visible = False
End Sub
Private Sub Command4_Click() ' Apply
On Error GoTo 1
If (Form1.MSComm1.PortOpen) Then
Form1.MSComm1.PortOpen = False
End If
Form1.MSComm1.CommPort = Mid$(COMt.Text, 1, 1)
Form1.MSComm1.Handshaking = Mid$(Flowcontrol.Text, 1, 1)
Form1.MSComm1.Settings = baud.Text + "," + Mid$(Parity.Text, 1, 1) + "," + DataBit.Text + "," + StopBit.Text
Form1.MSComm1.PortOpen = True
Exit Sub
1 MsgBox ("The serial port is already in use, Please set to the other port")
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -