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

📄 mainform.frm

📁 vb与串口通信的关于回路测试的小程序 很实用
💻 FRM
字号:
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   6030
   ClientLeft      =   45
   ClientTop       =   270
   ClientWidth     =   7605
   LinkTopic       =   "Form1"
   ScaleHeight     =   6030
   ScaleWidth      =   7605
   StartUpPosition =   3  '窗口缺省
   Begin VB.TextBox txtReceive 
      BeginProperty Font 
         Name            =   "Times New Roman"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   1500
      Left            =   3960
      MultiLine       =   -1  'True
      ScrollBars      =   2  'Vertical
      TabIndex        =   7
      Text            =   "Mainform.frx":0000
      Top             =   1920
      Width           =   2940
   End
   Begin MSCommLib.MSComm Comm1 
      Left            =   1104
      Top             =   576
      _ExtentX        =   794
      _ExtentY        =   794
      _Version        =   393216
      DTREnable       =   -1  'True
   End
   Begin VB.CommandButton CmdExit 
      Cancel          =   -1  'True
      Caption         =   "结束"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   876
      Left            =   2352
      Picture         =   "Mainform.frx":0006
      Style           =   1  'Graphical
      TabIndex        =   6
      Top             =   4944
      Width           =   2652
   End
   Begin VB.CommandButton CmdReceive 
      Caption         =   "读取字符串"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   924
      Left            =   4176
      Picture         =   "Mainform.frx":0448
      Style           =   1  'Graphical
      TabIndex        =   5
      Top             =   3648
      Width           =   2460
   End
   Begin VB.CommandButton CmdSend 
      Caption         =   "发送字符串"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   924
      Left            =   768
      Picture         =   "Mainform.frx":088A
      Style           =   1  'Graphical
      TabIndex        =   4
      Top             =   3648
      Width           =   2460
   End
   Begin VB.TextBox txtSend 
      BeginProperty Font 
         Name            =   "Times New Roman"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   1500
      Left            =   672
      MultiLine       =   -1  'True
      ScrollBars      =   2  'Vertical
      TabIndex        =   1
      Text            =   "Mainform.frx":0B94
      Top             =   1920
      Width           =   2940
   End
   Begin VB.Label Label3 
      AutoSize        =   -1  'True
      Caption         =   "**接收区**"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   240
      Index           =   1
      Left            =   4080
      TabIndex        =   3
      Top             =   1590
      Width           =   1200
   End
   Begin VB.Label Label3 
      AutoSize        =   -1  'True
      Caption         =   "**发送区**"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   240
      Index           =   0
      Left            =   765
      TabIndex        =   2
      Top             =   1635
      Width           =   1200
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      Caption         =   "RS-232范例1"
      BeginProperty Font 
         Name            =   "Times New Roman"
         Size            =   18
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FF0000&
      Height          =   390
      Left            =   2880
      TabIndex        =   0
      Top             =   120
      Width           =   2040
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
''''''''''''''''''''''''''''''''''''''
'使用命令按钮控件
'关闭通信端口
'结束系统
'
''''''''''''''''''''''''''''''''''''''
Private Sub CmdExit_Click()
 Comm1.PortOpen = False
 End
End Sub

''''''''''''''''''''''''''''''''''''''
'使用命令按钮控件
'接收由通信端口发送过来的字符串,并判断之
'
''''''''''''''''''''''''''''''''''''''
Private Sub CmdReceive_Click()
 Dim buf$
 buf = Trim(Comm1.Input) '将缓冲区内的数据收进buf变量中
 If Len(buf) = 0 Then '判断其中是否存在数据
 txtReceive.Text = "Empty"
 Else
 txtReceive.Text = buf
 End If
End Sub

''''''''''''''''''''''''''''''''''''''
'使用命令按钮控件
'将数据由通信端口发送出去
'
''''''''''''''''''''''''''''''''''''''
Private Sub CmdSend_Click()
 Comm1.Output = Trim(txtSend.Text)
End Sub

''''''''''''''''''''''''''''''''''''''
'窗体的加载事件
'打开通信端口,通信端口的设置参数也可以
'在打开前作设置
'
''''''''''''''''''''''''''''''''''''''
Private Sub Form_Load()
 Comm1.PortOpen = True
End Sub

⌨️ 快捷键说明

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