📄 form1.frm
字号:
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3780
ClientLeft = 60
ClientTop = 420
ClientWidth = 4170
Icon = "Form1.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
ScaleHeight = 3780
ScaleWidth = 4170
StartUpPosition = 2 '屏幕中心
Begin VB.PictureBox Picture1
Height = 975
Left = 2880
MousePointer = 2 'Cross
Picture = "Form1.frx":030A
ScaleHeight = 915
ScaleWidth = 1155
TabIndex = 11
Top = 2760
Width = 1215
End
Begin VB.TextBox Text3
Height = 270
Left = 3180
TabIndex = 9
Text = "1000"
Top = 2400
Width = 615
End
Begin VB.CheckBox Check1
Caption = "Check1"
Height = 270
Left = 2880
TabIndex = 8
Top = 2400
Width = 255
End
Begin VB.CommandButton Command4
Caption = "清空发送区"
Height = 495
Left = 2880
TabIndex = 7
Top = 1200
Width = 1215
End
Begin VB.CommandButton Command3
Caption = "清空接收区"
Height = 495
Left = 2880
TabIndex = 6
Top = 600
Width = 1215
End
Begin VB.Timer Timer1
Interval = 100
Left = 840
Top = 960
End
Begin MSCommLib.MSComm MSComm1
Left = 840
Top = 1920
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
DTREnable = -1 'True
End
Begin VB.CommandButton Command2
Caption = "Command2"
Height = 495
Left = 2880
TabIndex = 5
Top = 1800
Width = 1215
End
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 495
Left = 2880
TabIndex = 4
Top = 0
Width = 1215
End
Begin VB.Frame Frame2
Caption = "发送数据"
Height = 1815
Left = 0
TabIndex = 2
Top = 1920
Width = 2775
Begin VB.TextBox Text2
BackColor = &H00FFFFFF&
Height = 1455
Left = 0
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 3
Top = 240
Width = 2655
End
End
Begin VB.Frame Frame1
Caption = "接收数据"
Height = 1815
Left = 0
TabIndex = 0
Top = 0
Width = 2775
Begin VB.Timer Timer2
Left = 1680
Top = 1440
End
Begin VB.TextBox Text1
BackColor = &H00FFFFFF&
Height = 1455
Left = 0
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 1
Top = 240
Width = 2655
End
End
Begin VB.Label Label1
Caption = "ms"
Height = 270
Left = 3840
TabIndex = 10
Top = 2400
Width = 255
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private oldH, oldW
Private Sub Check1_Click()
If Check1.Value = 1 Then
Timer2.Interval = Val(Text3.Text)
Timer2.Enabled = True
Else
Timer2.Enabled = False
End If
End Sub
Private Sub Command1_Click()
Select Case Command1.Caption
Case "打开串口"
MSComm1.PortOpen = True
Command1.Caption = "关闭串口"
Command2.Enabled = True
Check1.Enabled = True
Text3.Locked = False
Case "关闭串口"
MSComm1.PortOpen = False
Command1.Caption = "打开串口"
Command2.Enabled = False
Check1.Enabled = False
Check1.Value = 0
Text3.Locked = True
End Select
End Sub
Private Sub Command2_Click()
If MSComm1.PortOpen = True Then
MSComm1.Output = Text2.Text
Else
MsgBox "串口未打开", vbInformation + vbOKOnly, "提示"
End If
End Sub
Private Sub Command3_Click()
Text1.Text = ""
End Sub
Private Sub Command4_Click()
Text2.Text = ""
End Sub
Private Sub Form_Load()
Command1.Caption = "打开串口"
Command2.Caption = "发送数据"
Command2.Enabled = False
Check1.Enabled = False
Timer2.Enabled = False
Text3.Locked = True
oldH = Me.Height
oldW = Me.Width
End Sub
Private Sub Form_Resize()
On Error Resume Next
Me.Width = oldW
Me.Height = oldH
Select Case Me.WindowState
Case 0
Me.Caption = "串口调试软件"
Case 1
Me.Caption = "あ邂逅記憶あ"
End Select
End Sub
Private Sub MSComm1_OnComm()
If MSComm1.CommEvent = comEvReceive Then
indata = MSComm1.Input
MSComm1.InBufferCount = 0
End If
End Sub
Private Sub Picture1_Click()
MsgBox "串口调试软件" & vbCrLf & "软件作者:杨勇" & vbCrLf & "2007年3月9日" & vbCrLf & "谢谢使用", vbInformation + vbOKOnly, "软件信息"
End Sub
Private Sub Text3_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case Is = 8
Exit Sub
Case Is < 48
KeyAscii = 0
Case Is > 57
KeyAscii = 0
End Select
End Sub
Private Sub Timer1_Timer()
If MSComm1.PortOpen = True And MSComm1.InBufferCount <> 0 Then
indata = MSComm1.Input
If Text1.Text = "" Then
Text1.Text = indata
Else
Text1.Text = Text1.Text & indata
End If
End If
End Sub
Private Sub Timer2_Timer()
If MSComm1.PortOpen = True And Text2.Text <> "" Then
MSComm1.Output = Text2.Text
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -