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

📄 form1.frm

📁 ComPort Transfer using Visual Basic
💻 FRM
字号:
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   3090
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   4680
   LinkTopic       =   "Form1"
   ScaleHeight     =   3090
   ScaleWidth      =   4680
   StartUpPosition =   3  'Windows Default
   Begin VB.Timer Timer1 
      Left            =   120
      Top             =   1200
   End
   Begin MSCommLib.MSComm MSComm1 
      Left            =   120
      Top             =   2280
      _ExtentX        =   1005
      _ExtentY        =   1005
      _Version        =   393216
      DTREnable       =   -1  'True
   End
   Begin VB.CommandButton cmdQuit 
      Caption         =   "QUIT"
      Height          =   495
      Left            =   2400
      TabIndex        =   3
      Top             =   1920
      Width           =   1215
   End
   Begin VB.CommandButton cmdSend 
      Caption         =   "SEND"
      Height          =   495
      Left            =   600
      TabIndex        =   2
      Top             =   1920
      Width           =   1215
   End
   Begin VB.TextBox txtReceive 
      Height          =   495
      Left            =   2400
      TabIndex        =   1
      Top             =   360
      Width           =   1215
   End
   Begin VB.TextBox txtSend 
      Height          =   495
      Left            =   600
      TabIndex        =   0
      Top             =   360
      Width           =   1215
   End
   Begin VB.Label Label1 
      Caption         =   "Not connected"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H000000C0&
      Height          =   495
      Left            =   2040
      TabIndex        =   4
      Top             =   1080
      Width           =   2055
   End
   Begin VB.Shape Shape1 
      FillColor       =   &H000000FF&
      FillStyle       =   0  'Solid
      Height          =   495
      Left            =   720
      Shape           =   3  'Circle
      Top             =   960
      Width           =   1215
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim a As Boolean
Private Sub cmdQuit_Click()
MSComm1.PortOpen = False

End
End Sub

Private Sub cmdSend_Click()
'message = "HELLO"
message = &H1500
txtSend.Text = Hex(message)
'MSComm1.Output = Str(message)
MSComm1.Output = txtSend.Text
Timer1.Enabled = True
a = True
Label1.Visible = False
Shape1.FillColor = vbRed
End Sub

Private Sub Form_Load()

If MSComm1.PortOpen Then MSComm1.PortOpen = False
With MSComm1
.CommPort = 4
.Settings = "19200,n,8,1"
.RThreshold = 1
.InputMode = 0
.PortOpen = True
End With
Label1.Visible = False
Timer1.Interval = 1000
Timer1.Enabled = False
Shape1.FillColor = vbRed
End Sub


Private Sub MSComm1_OnComm()
If MSComm1.CommEvent = comEvReceive Then

txtReceive.Text = MSComm1.Input
a = False
End If
End Sub

Private Sub Timer1_Timer()
If a Then
Shape1.FillColor = vbBlue
Label1.Visible = True
Beep

End If
Timer1.Enabled = False
End Sub

⌨️ 快捷键说明

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