main.frm

来自「详细介绍M8两版间通讯」· FRM 代码 · 共 63 行

FRM
63
字号
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Begin VB.Form Ctrl 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "AtMega8"
   ClientHeight    =   6270
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   8025
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   6270
   ScaleWidth      =   8025
   StartUpPosition =   3  '窗口缺省
   Begin MSCommLib.MSComm MSComm1 
      Left            =   6360
      Top             =   480
      _ExtentX        =   1005
      _ExtentY        =   1005
      _Version        =   393216
      DTREnable       =   0   'False
      InputLen        =   1
      RThreshold      =   1
      BaudRate        =   19200
   End
End
Attribute VB_Name = "Ctrl"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub Form_Load()
With MSComm1
  .CommPort = 1
  .Settings = "19200,n,8,1"
  .PortOpen = True
End With
End Sub

Private Sub Form_Unload(Cancel As Integer)
MSComm1.PortOpen = False
End Sub

Private Sub MSComm1_OnComm()
Dim charTemp As String * 1
Static IsStart As Boolean
charTemp = MSComm1.Input
If charTemp = "c" Then
  IsStart = True
ElseIf IsStart = True Then
  If charTemp = "f" Then
    MSComm1.Output = "c"
    Me.Print "已经正确收到"
    Else
    IsStart = False
  End If
End If

End Sub

⌨️ 快捷键说明

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