📄 rs232.frm
字号:
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3195
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3195
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton com_exit
Caption = "退出"
Height = 375
Left = 2040
TabIndex = 4
Top = 2640
Width = 255
End
Begin VB.CommandButton com_clear
Caption = "clear"
Height = 375
Left = 1920
TabIndex = 3
Top = 2040
Width = 495
End
Begin VB.TextBox displaytext
Height = 1815
Left = 2880
TabIndex = 2
Text = "Text2"
Top = 480
Width = 1575
End
Begin VB.TextBox inputtext
Height = 1815
Left = 120
TabIndex = 1
Text = "Text1"
Top = 480
Width = 1455
End
Begin VB.CommandButton com_send
Caption = "发送"
Height = 375
Left = 1800
TabIndex = 0
Top = 480
Width = 495
End
Begin MSCommLib.MSComm MSComm1
Left = 1800
Top = 1080
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
DTREnable = -1 'True
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim instring As String
Dim s As String
Private Sub com_clear_Click()
inputtext.Text = ""
End Sub
Private Sub com_exit_Click()
MSComm1.PortOpen = False
s = ""
instring = ""
End
End Sub
Private Sub com_send_Click()
On Error Resume Next
If inputtext.Text = "" Then
x = MsgBox("您输入的为空值", 16)
Exit Sub
End If
MSComm1.Output = inputtext.Text
End Sub
Private Sub Form_Load()
s = ""
instring = ""
inputtext.Text = ""
MSComm1.RThreshold = 1
displaytext = ""
MSComm1.CommPort = 1
MSComm1.Settings = "9600,n,8,1"
If MSComm1.PortOpen = False Then
MSComm1.PortOpen = True
End If
End Sub
Private Sub MSComm1_OnComm()
s = MSComm1.Input
instring = instring + s
displaytext.Text = instring
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -