📄 form1.frm
字号:
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 4980
ClientLeft = 60
ClientTop = 345
ClientWidth = 6975
LinkTopic = "Form1"
ScaleHeight = 4980
ScaleWidth = 6975
StartUpPosition = 3 '窗口缺省
Begin MSCommLib.MSComm MSComm1
Left = 4680
Top = 3840
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
DTREnable = 0 'False
InBufferSize = 10
OutBufferSize = 10
RThreshold = 1
BaudRate = 4800
StopBits = 2
InputMode = 1
End
Begin VB.CommandButton Command2
Caption = "退出"
Height = 495
Left = 2400
TabIndex = 5
Top = 3360
Width = 1335
End
Begin VB.CommandButton Command1
Caption = "发送"
Height = 495
Left = 840
TabIndex = 4
Top = 3360
Width = 1215
End
Begin VB.TextBox Text2
Height = 1695
Left = 1320
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 1
Top = 1200
Width = 2655
End
Begin VB.TextBox Text1
Height = 375
Left = 1440
MultiLine = -1 'True
TabIndex = 0
Top = 600
Width = 1575
End
Begin VB.Label Label2
Alignment = 2 'Center
Caption = "接受"
Height = 495
Left = 240
TabIndex = 3
Top = 1320
Width = 975
End
Begin VB.Label Label1
Alignment = 2 'Center
Caption = "发送"
Height = 495
Left = 120
TabIndex = 2
Top = 600
Width = 1215
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim i As Integer
Private Sub Mscomm1_Oncomm()
Dim a As String
Select Case MSComm1.CommEvent
Case comEvReceive
a = MSComm1.Input
Text2.Text = Text2.Text + a
MSComm1.InBufferCount = 0
End Select
End Sub
Private Sub Command1_Click()
Dim a%
a = InputBox("123")
MSComm1.Output = CStr(a)
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
MSComm1.CommPort = 2
MSComm1.Settings = "9600,n,8,1"
MSComm1.PortOpen = True
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -