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

📄 我的串口通讯对八达.frm

📁 该文件中包含了上位机和控制设备间的通讯代码
💻 FRM
字号:
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   5490
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   7275
   LinkTopic       =   "Form1"
   ScaleHeight     =   5490
   ScaleWidth      =   7275
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command2 
      Caption         =   "Command2"
      Height          =   375
      Left            =   3360
      TabIndex        =   6
      Top             =   2160
      Width           =   495
   End
   Begin VB.TextBox Text5 
      Height          =   375
      Left            =   4920
      TabIndex        =   5
      Text            =   "11"
      Top             =   1440
      Width           =   855
   End
   Begin VB.TextBox Text4 
      Height          =   2295
      Left            =   120
      MultiLine       =   -1  'True
      ScrollBars      =   2  'Vertical
      TabIndex        =   4
      Text            =   "我的串口通讯对八达.frx":0000
      Top             =   3000
      Width           =   6975
   End
   Begin VB.CommandButton Command1 
      Caption         =   "Command1"
      Height          =   375
      Left            =   2160
      TabIndex        =   3
      Top             =   2160
      Width           =   735
   End
   Begin VB.TextBox Text3 
      Height          =   375
      Left            =   120
      TabIndex        =   2
      Text            =   "Text3"
      Top             =   840
      Width           =   6855
   End
   Begin VB.TextBox Text2 
      Height          =   375
      Left            =   1200
      TabIndex        =   1
      Text            =   "Text2"
      Top             =   240
      Width           =   615
   End
   Begin VB.TextBox Text1 
      Height          =   375
      Left            =   240
      TabIndex        =   0
      Text            =   "Text1"
      Top             =   240
      Width           =   615
   End
   Begin MSCommLib.MSComm MSComm1 
      Left            =   360
      Top             =   2040
      _ExtentX        =   1005
      _ExtentY        =   1005
      _Version        =   393216
      DTREnable       =   0   'False
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Dim x(0) As Byte
Dim x1(0) As Byte
Dim x2(0) As Byte
Dim x3(0) As Byte
Dim a As Variant
x(0) = 3
x1(0) = 2
x2(0) = 32
x3(0) = 37
a = x()
MSComm1.Settings = "9600,o,8,1"
MSComm1.Output = a
a = x1()
MSComm1.Settings = "9600,o,8,1"
MSComm1.Output = a
a = x2()
MSComm1.Settings = "9600,o,8,1"
MSComm1.Output = a
a = x3()
MSComm1.Settings = "9600,o,8,1"
MSComm1.Output = a

End Sub

Private Sub Command2_Click()
    If bbc = 1 Then
    GoTo aa2
    Else: GoTo aa3
    End If
    
aa3:    a3 = 0
    a4 = 1
    MSComm1.Settings = "9600,n,8,1"
    MSComm1.SThreshold = 0
    bbc = 1
    MSComm1.Output = Text5.Text 't1
aa2:

End Sub

Private Sub Form_Load()
MSComm1.CommPort = 1
MSComm1.InBufferSize = 1
MSComm1.InputLen = 1
MSComm1.InputMode = comInputModeBinary
MSComm1.OutBufferSize = 512
MSComm1.RThreshold = 10
MSComm1.SThreshold = 0 '9
MSComm1.Settings = "9600,n,8,1"
MSComm1.PortOpen = True

End Sub

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

Private Sub MSComm1_OnComm()
Dim zz As String
Dim z As Variant
Dim zzz(222) As Byte

z = MSComm1.Input
Text4.Text = Text4.Text & " " & z(0)
'Text5.Text = z(1)
'Text5.Text = z(0) 'z = zz
' z = z & MSComm1.Input
 
aa1: a1 = 1

End Sub

⌨️ 快捷键说明

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