⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.frm

📁 利用VB COMMCOM控件读串口数据源码
💻 FRM
字号:
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   4950
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   7650
   LinkTopic       =   "Form1"
   ScaleHeight     =   4950
   ScaleWidth      =   7650
   StartUpPosition =   3  '窗口缺省
   Begin MSCommLib.MSComm MSComm1 
      Left            =   5040
      Top             =   1920
      _ExtentX        =   1005
      _ExtentY        =   1005
      _Version        =   393216
      DTREnable       =   -1  'True
      InputLen        =   4
      InputMode       =   1
   End
   Begin VB.Timer Timer2 
      Interval        =   60000
      Left            =   3240
      Top             =   2040
   End
   Begin VB.Timer Timer1 
      Enabled         =   0   'False
      Interval        =   30000
      Left            =   1680
      Top             =   2040
   End
   Begin VB.CommandButton Command2 
      Caption         =   "停止"
      Height          =   495
      Left            =   4680
      TabIndex        =   2
      Top             =   3240
      Width           =   1215
   End
   Begin VB.CommandButton Command1 
      Caption         =   "运行"
      Height          =   495
      Left            =   1200
      TabIndex        =   1
      Top             =   3240
      Width           =   1215
   End
   Begin VB.TextBox Text1 
      Height          =   615
      Left            =   4320
      TabIndex        =   0
      Text            =   "Text1"
      Top             =   600
      Width           =   2415
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim av As Variant
Dim shuzhi As Single

Private Sub Command1_Click()
MSComm1.PortOpen = True

End Sub

Private Sub MSComm1_OnComm()
MSComm1.PortOpen = False
With MSComm1
Select Case .CommEvent
       Case comEvReceive
       av = MSComm.Input
 End Select
 End With
 
       
 Text1.Text = av
 Timer1.Enabled = True
 

End Sub

Private Sub Timer1_Timer()
MSComm1.PortOpen = True
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -