📄 form1.frm
字号:
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Begin VB.Form Form1
BackColor = &H80000004&
Caption = "COM COMM"
ClientHeight = 6720
ClientLeft = 45
ClientTop = -45
ClientWidth = 6825
BeginProperty Font
Name = "楷体_GB2312"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Icon = "Form1.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
ScaleHeight = 6720
ScaleWidth = 6825
StartUpPosition = 1 '所有者中心
Begin VB.CommandButton Command9
Caption = "Clear"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 390
Left = 5175
TabIndex = 18
Top = 4650
Width = 915
End
Begin VB.CommandButton Command8
Caption = "PORT ON"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 390
Left = 5025
TabIndex = 17
Top = 6075
Width = 990
End
Begin VB.CommandButton Command7
Caption = "PORT OFF"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 390
Left = 4050
TabIndex = 16
Top = 6075
Width = 915
End
Begin VB.CommandButton Command6
Caption = "S AND R"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 465
Left = 1350
TabIndex = 15
Top = 5400
Width = 1065
End
Begin VB.CommandButton Command5
Caption = "SEND"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 465
Left = 300
TabIndex = 14
Top = 5400
Width = 915
End
Begin VB.Timer Timer1
Interval = 100
Left = 5400
Top = 6150
End
Begin VB.CommandButton Command4
BackColor = &H8000000A&
Caption = "OFFLINE"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 480
Left = 1350
MousePointer = 99 'Custom
Style = 1 'Graphical
TabIndex = 12
ToolTipText = "关闭端口"
Top = 6000
Width = 1050
End
Begin VB.TextBox Text1
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 285
Left = 1860
TabIndex = 10
Top = 900
Width = 4695
End
Begin VB.CommandButton Command3
Caption = "SETUP"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 480
Left = 2550
MousePointer = 99 'Custom
Style = 1 'Graphical
TabIndex = 4
Top = 5400
Width = 1140
End
Begin VB.CommandButton Command2
BackColor = &H8000000A&
Caption = "EXIT"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 480
Left = 2550
MousePointer = 99 'Custom
Style = 1 'Graphical
TabIndex = 3
Top = 6000
Width = 1125
End
Begin MSCommLib.MSComm MSComm1
Left = 6000
Top = 5700
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
DTREnable = -1 'True
BaudRate = 2400
ParitySetting = 2
DataBits = 7
End
Begin VB.TextBox Text4
BackColor = &H0080FFFF&
BeginProperty Font
Name = "黑体"
Size = 13.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 3675
Left = 120
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 2
Top = 1380
Width = 6555
End
Begin VB.CommandButton Command1
BackColor = &H8000000A&
Caption = "Receive"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 480
Left = 300
MousePointer = 99 'Custom
Style = 1 'Graphical
TabIndex = 1
Top = 6000
Width = 900
End
Begin VB.Label Label8
Alignment = 2 'Center
AutoSize = -1 'True
BackStyle = 0 'Transparent
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H000000FF&
Height = 210
Left = 4125
TabIndex = 13
Top = 5100
Width = 120
End
Begin VB.Label Label7
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "SAVEFILE PATH"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H000000FF&
Height = 240
Left = 150
TabIndex = 11
Top = 900
Width = 1560
End
Begin VB.Label Label6
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "Label6"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 210
Left = 4350
TabIndex = 9
Top = 450
Width = 630
End
Begin VB.Label Label5
AutoSize = -1 'True
BackColor = &H00FF00FF&
BackStyle = 0 'Transparent
Caption = "FLOW:"
ForeColor = &H000000FF&
Height = 285
Left = 3420
TabIndex = 8
Top = 420
Width = 825
End
Begin VB.Label Label4
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "Label4"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 210
Left = 1800
TabIndex = 7
Top = 525
Width = 630
End
Begin VB.Label Label3
AutoSize = -1 'True
BackColor = &H00FF00FF&
BackStyle = 0 'Transparent
Caption = "COM PORT:"
ForeColor = &H000000FF&
Height = 285
Left = 240
TabIndex = 6
Top = 480
Width = 1485
End
Begin VB.Label Label2
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "Label2"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 210
Left = 1800
TabIndex = 5
Top = 150
Width = 630
End
Begin VB.Label Label1
AutoSize = -1 'True
BackColor = &H00FF00FF&
BackStyle = 0 'Transparent
Caption = "SET INFO:"
ForeColor = &H000000FF&
Height = 285
Left = 240
TabIndex = 0
Top = 120
Width = 1485
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim Pd As Boolean
Private Sub Command1_Click()
Label8.Caption = "Receive..."
' 保存输入子串的缓冲区
Dim Instring As String
MSComm1.PortOpen = True
On Error Resume Next
'轮询数据
'MsgBox MSComm1.RTSEnable
10 Do
DoEvents
Loop Until MSComm1.InBufferCount >= 1
Instring = MSComm1.Input
Open Trim(Text1.Text) For Append As #1
Print #1, Instring
Close
Text4 = Text4 + Instring
GoTo 10
End Sub
Private Sub Command2_Click()
If MSComm1.PortOpen = True Then MSComm1.PortOpen = False
End
End Sub
Private Sub Command3_Click()
frmProperties.Show
End Sub
Private Sub Command4_Click()
If MSComm1.PortOpen = True Then MSComm1.PortOpen = False: Label8.Caption = "PORT OFF!"
Close All
End Sub
Private Sub Command5_Click()
MSComm1.PortOpen = True
MSComm1.Output = Text4.Text
MSComm1.PortOpen = False
End Sub
Private Sub Command6_Click()
'Text4.Text = ""
MSComm1.PortOpen = True
MSComm1.Output = Text4.Text
Label8.Caption = "Receive..."
20 Do
DoEvents
Loop Until MSComm1.InBufferCount >= 1
Instring = MSComm1.Input
Open Trim(Text1.Text) For Append As #2
Print #2, Instring
Close
Text4 = Text4 + Instring
GoTo 20
MSComm1.PortOpen = False
End Sub
Private Sub Command7_Click()
MSComm1.PortOpen = False
End Sub
Private Sub Command8_Click()
MSComm1.PortOpen = True
End Sub
Private Sub Command9_Click()
Text4.Text = ""
End Sub
Private Sub Form_Load()
If MSComm1.PortOpen = True Then MSComm1.PortOpen = False
Me.Show
Form1.MSComm1.Settings = GetSetting(App.Title, "Properties", "Settings", "9600,e,8,1")
Label2.Caption = Form1.MSComm1.Settings
Form1.MSComm1.CommPort = GetSetting(App.Title, "Properties", "CommPort", 1)
Label4.Caption = Form1.MSComm1.CommPort
Form1.MSComm1.Handshaking = GetSetting(App.Title, "Properties", "Handshaking", 0)
Label6.Caption = Form1.MSComm1.Handshaking
Dim Time0 As String
Time0 = Trim(CStr(Time))
If Time0 < "0:10:00" And Time0 > "0:00:00" Then
Text1.Text = App.Path + "\" + Trim(Str(Year(Date))) + Trim(Str(Month(Date))) + Trim(Str(Day(Date) - 1)) + ".txt"
Else
Text1.Text = App.Path + "\" + Trim(Str(Year(Date))) + Trim(Str(Month(Date))) + Trim(Str(Day(Date))) + ".txt"
End If
Pd = False
End Sub
Private Sub Form_Unload(Cancel As Integer)
If MSComm1.PortOpen = True Then MSComm1.PortOpen = False
End
End Sub
Private Sub Text4_Change()
Pd = True
End Sub
Private Sub Text4_Click()
Command4_Click
End Sub
Private Sub Timer1_Timer()
Dim Time0 As String
Time0 = Trim(CStr(Time))
If Time0 = "0:10:00" Then
Text1.Text = App.Path + "\" + Trim(Str(Year(Date))) + Trim(Str(Month(Date))) + Trim(Str(Day(Date))) + ".txt"
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -