📄 字符仿真器.frm
字号:
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Begin VB.Form Form1
BackColor = &H00E0E0E0&
BorderStyle = 3 'Fixed Dialog
Caption = "Form1"
ClientHeight = 5265
ClientLeft = 45
ClientTop = 435
ClientWidth = 7005
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 5265
ScaleWidth = 7005
ShowInTaskbar = 0 'False
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command1
Caption = "接收数据"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 2640
TabIndex = 4
Top = 240
Width = 1695
End
Begin MSCommLib.MSComm MSComm1
Left = 6360
Top = 120
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
DTREnable = -1 'True
RThreshold = 1
End
Begin VB.ListBox ComList
Height = 3300
Left = 960
TabIndex = 3
Top = 1440
Width = 5055
End
Begin VB.CommandButton cmdClear
Caption = "清除命令"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 4320
TabIndex = 1
Top = 240
Width = 1695
End
Begin VB.CommandButton cmdClose
Caption = "关闭仿真器"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 960
TabIndex = 0
Top = 240
Width = 1695
End
Begin VB.Label Label1
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "显示命令:"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 240
Left = 960
TabIndex = 2
Top = 960
Width = 1200
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit '强制显示声名变量
Private Declare Function GetTickCount Lib "kernel32" () As Long
Private Sub cmdClear_Click()
ComList.Clear
End Sub
Private Sub cmdClose_Click()
End
End Sub
Private Sub Command1_Click()
Dim t&, Buf$, StrPos%
Select Case MSComm1.CommEvent
Case comEvCD
Case comEvCTS
Case comEvDSR
Case comEvRing
Case comEvReceive
t = GetTickCount()
Do
DoEvents
Loop Until GetTickCount - 1 > 100
Buf = Trim(MSComm1.Input)
If Len(Buf) < 2 Then Exit Sub
StrPos = InStr(1, Buf, "NC")
If StrPos < 1 Then
MSComm1.Output = "命令错误!"
ComList.AddItem "收到命令!" & Right(Buf, Len(Buf) - (StrPos + 1))
ComList.AddItem "命令错误!"
Else
MSComm1.Output = "执行命令!" & Right(Buf, Len(Buf) - (StrPos + 1))
ComList.AddItem "收到命令!" & Right(Buf, Len(Buf) - (StrPos + 1))
ComList.AddItem "命令正确!"
End If
Case comEvSend
End Select
End Sub
Private Sub Form_Load()
MSComm1.PortOpen = True
End Sub
Private Sub Form_Unload(Cancel As Integer)
MSComm1.PortOpen = False
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -