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

📄 liu.frm

📁 C51源程序集锦 This a demo program showing a way to perform simultaneous RS-232 transmit and receive us
💻 FRM
字号:
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Begin VB.Form Form1 
   AutoRedraw      =   -1  'True
   Caption         =   "Form1"
   ClientHeight    =   3195
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4680
   LinkTopic       =   "Form1"
   ScaleHeight     =   3195
   ScaleWidth      =   4680
   StartUpPosition =   3  'Windows Default
   Begin VB.TextBox Text1 
      Height          =   1695
      Left            =   240
      MultiLine       =   -1  'True
      TabIndex        =   1
      Top             =   120
      Width           =   4215
   End
   Begin VB.CommandButton button1 
      Caption         =   "Key1"
      Height          =   615
      Left            =   1920
      TabIndex        =   0
      Top             =   2400
      Width           =   1695
   End
   Begin MSCommLib.MSComm com2 
      Left            =   240
      Top             =   2400
      _ExtentX        =   1005
      _ExtentY        =   1005
      _Version        =   327680
      CommPort        =   2
      DTREnable       =   0   'False
      InputLen        =   10
      RThreshold      =   1
      BaudRate        =   4800
      SThreshold      =   1
      InputMode       =   1
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Sub button1_Click()
Dim senddata(5) As Byte
Dim recedata() As Byte
Dim i As Integer
Dim ii As Integer
Dim endflag As Integer
Close
Dim maxdelay As Integer

com2.PortOpen = True

 senddata(0) = 255
 senddata(1) = 255
 senddata(2) = 1
 senddata(3) = 255
 senddata(4) = 255
 senddata(5) = 255
 
com2.Output = senddata
endflag = 0
maxdelay = 30000

Do Until com2.InBufferCount > 51
    If endflag > maxdelay Then Exit Do
       DoEvents
       endflag = endflag + 1
Loop

If com2.InBufferCount > 51 Then
      com2.InputLen = 52
      recedata = com2.Input
    ' display text to text1 frame
    
    Text1 = ""
   For ii = 0 To 51
  '     Text1 = Text1 + Str(recedata(ii) / 2) + ","
         Text1 = Text1 + Str(recedata(ii)) + " "
   Next ii
End If

If endflag > maxdelay Then
    MsgBox "No Data Receive", 48, "Error"
End If
com2.PortOpen = False
End Sub

⌨️ 快捷键说明

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