📄 ohi.frm
字号:
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3090
ClientLeft = 60
ClientTop = 450
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3090
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton cmdTest
Caption = "cmdTest"
Height = 495
Left = 1680
TabIndex = 0
Top = 1920
Width = 1455
End
Begin MSCommLib.MSComm MSComm1
Left = 2160
Top = 480
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
CommPort = 2
DTREnable = -1 'True
RThreshold = 1
BaudRate = 115200
StopBits = 2
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim Buffer As Variant
Private Sub cmdTest_Click()
'设定Com2口
If MSComm1.PortOpen = False Then
MSComm1.Settings = "19200,N,8,1" '115200波特率,无校验,8位数据位,1位停止位
MSComm1.PortOpen = True '打开串
MSComm1.OutBufferCount = 0 '清空发送缓冲区
MSComm1.InBufferCount = 0
End If
MSComm1.Output = "this is a try!"
'发送字符数据,注意必须用回车符(vbCr)结束
End Sub
Private Sub Form_Click()
Buffer = MSComm1.Input
MsgBox (Buffer)
End Sub
Private Sub Form_Load()
MSComm1.CommPort = 1
End Sub
Private Sub MSComm1_OnComm()
Select Case MSComm1.CommEvent
Case comEvReceive '接收字符数据
MSComm1.InputLen = 15
'当InputMode 属性值为0(文本模式)时,变量中含String型数据。
'当InputMode属性值为1(二进制模式)时,变量中含Byte型数组数据。
MSComm1.InputMode = comInputModeText
' MSComm1.InputMode = comInputModeBinar
'清空接收缓冲区y
' Buffer = MSComm1.Input '接收二进制数据
Case Else
End Select
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -