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

📄 mainform.frm

📁 串口示例程序对visualbasic的串口通讯不熟悉的可以参考
💻 FRM
字号:
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Begin VB.Form MainForm 
   AutoRedraw      =   -1  'True
   Caption         =   "Form1"
   ClientHeight    =   7470
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   8430
   LinkTopic       =   "Form1"
   ScaleHeight     =   7470
   ScaleWidth      =   8430
   StartUpPosition =   3  '窗口缺省
   Begin VB.Timer Timer2 
      Left            =   600
      Top             =   5160
   End
   Begin VB.Timer Timer1 
      Left            =   1800
      Top             =   4800
   End
   Begin MSCommLib.MSComm MSComm1 
      Left            =   1200
      Top             =   2040
      _ExtentX        =   1005
      _ExtentY        =   1005
      _Version        =   393216
      DTREnable       =   -1  'True
   End
   Begin VB.CommandButton Command1 
      Caption         =   "Command1"
      Height          =   735
      Left            =   480
      TabIndex        =   2
      Top             =   3600
      Width           =   2055
   End
   Begin VB.TextBox Text2 
      Height          =   495
      Left            =   120
      TabIndex        =   1
      Top             =   240
      Width           =   3135
   End
   Begin VB.TextBox Text1 
      Height          =   6615
      Left            =   3720
      MultiLine       =   -1  'True
      ScrollBars      =   2  'Vertical
      TabIndex        =   0
      Top             =   120
      Width           =   4455
   End
End
Attribute VB_Name = "MainForm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
MSComm1.Output = Text2.Text & Chr$(13)
Text2.SelStart = 0
Text2.SelLength = Len(Text2.Text)
Text2.SetFocus
End Sub

Private Sub Form_Load()
    MainForm.MSComm1.CommPort = 1
    MainForm.MSComm1.Settings = "115200,n,8,1"
    MainForm.MSComm1.InBufferSize = 1024
    MainForm.MSComm1.OutBufferSize = 1024
    MainForm.MSComm1.InputLen = 0
    MainForm.MSComm1.InBufferCount = 0
    MainForm.MSComm1.OutBufferCount = 0
    MainForm.MSComm1.PortOpen = True
    Timer2.Interval = 10
    Timer2.Enabled = True
    Timer1.Enabled = False
End Sub

Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then Command1 = True
End Sub

Private Sub Timer1_Timer()
Timer1.Enabled = False
End Sub

Private Sub Timer2_Timer()
Text1.Text = Text1.Text & MSComm1.Input
Text1.SelStart = Len(Text1.Text) + 10
End Sub

⌨️ 快捷键说明

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