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

📄 comtest.frm

📁 这是一个用于调试单片机与计算机通信的测试程序
💻 FRM
字号:
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Begin VB.Form Form1 
   AutoRedraw      =   -1  'True
   Caption         =   " Serial Port Tester     Creat Digital Tech. Corp.  Email: figaro@163.net"
   ClientHeight    =   915
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   6465
   BeginProperty Font 
      Name            =   "Terminal"
      Size            =   9
      Charset         =   255
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   Icon            =   "ComTest.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   915
   ScaleWidth      =   6465
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton cmdSendData 
      Caption         =   "Send"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   300
      Left            =   5640
      TabIndex        =   1
      ToolTipText     =   "Send 32 HEX data"
      Top             =   120
      Width           =   735
   End
   Begin VB.TextBox Text1 
      BackColor       =   &H00FF0000&
      BeginProperty Font 
         Name            =   "Courier"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FFFFFF&
      Height          =   348
      Left            =   960
      MaxLength       =   32
      TabIndex        =   0
      Top             =   120
      Width           =   4575
   End
   Begin MSCommLib.MSComm MSComm1 
      Left            =   4920
      Top             =   0
      _ExtentX        =   1005
      _ExtentY        =   1005
      _Version        =   393216
      CommPort        =   2
      DTREnable       =   -1  'True
      OutBufferSize   =   1024
      BaudRate        =   300
   End
   Begin VB.Label Label3 
      Alignment       =   2  'Center
      BorderStyle     =   1  'Fixed Single
      Caption         =   "Settings = ""9600,N,8,1"",   Send buffer = 32,   port = COM1. "
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   960
      TabIndex        =   3
      Top             =   600
      Width           =   4575
   End
   Begin VB.Label Label1 
      Alignment       =   1  'Right Justify
      Caption         =   "Send Data"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   0
      TabIndex        =   2
      Top             =   120
      Width           =   855
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
' =======================================================================================
' Communication with M51 by COM_Port for test port
' =======================================================================================
' This project is used with "SAMP_LCD" in Keil\CCC\.
'
' =======================================================================================

Option Explicit
Option Base 1
'

Private Sub Form_Load()
            
    MSComm1.CommPort = 1                    ' 使用 COM1。
    MSComm1.Settings = "9600,N,8,1"         ' 1200 波特,无奇偶校验,8 位数据,一个停止位。
    MSComm1.InputLen = 0                    ' 当输入占用时,告诉控件读入整个缓冲区。
    MSComm1.PortOpen = True                 ' 打开端口。
    MSComm1.RThreshold = 32                 ' 引发comEvReceive事件的最少输入Bytes
    
    Text1.Text = "0123456789ABCDEFGHIJKLMNOPQRSTUV"
    
End Sub

Private Sub cmdSendData_Click()
    
    Dim OutBuf As String                            ' out tata with binary
    
    OutBuf = Text1.Text                             ' 将 DATA 送到串行端口。
    If OutBuf = "" Then MsgBox ("请输入数据!")
    MSComm1.Output = OutBuf                         ' Send out data in OutBuf
    Beep

End Sub

Private Sub Form_Unload(Cancel As Integer)
    
    MSComm1.PortOpen = False                        ' 关闭串行端口。
    End

End Sub

' =======================================================================================

⌨️ 快捷键说明

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