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

📄 1.frm

📁 模拟屏 实时控制 监测 报警 监测报告
💻 FRM
字号:
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Begin VB.Form Form1 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "设置串口"
   ClientHeight    =   3300
   ClientLeft      =   45
   ClientTop       =   540
   ClientWidth     =   4290
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   3300
   ScaleMode       =   0  'User
   ScaleWidth      =   2191.571
   ShowInTaskbar   =   0   'False
   Begin VB.Timer Timer2 
      Left            =   120
      Top             =   1320
   End
   Begin VB.Timer Timer1 
      Left            =   3360
      Top             =   1080
   End
   Begin VB.CommandButton Command1 
      Caption         =   "返回"
      Height          =   375
      Left            =   2280
      TabIndex        =   5
      Top             =   2160
      Width           =   1095
   End
   Begin VB.ComboBox Combo1 
      Height          =   300
      ItemData        =   "1.frx":0000
      Left            =   2160
      List            =   "1.frx":000A
      TabIndex        =   2
      Text            =   "COM1"
      Top             =   480
      Width           =   1095
   End
   Begin VB.CommandButton Command4 
      Caption         =   "打开串口"
      Height          =   375
      Left            =   840
      TabIndex        =   1
      Top             =   2160
      Width           =   1095
   End
   Begin VB.ComboBox Combo2 
      Height          =   300
      ItemData        =   "1.frx":001A
      Left            =   2160
      List            =   "1.frx":002D
      TabIndex        =   0
      Text            =   "19200"
      Top             =   1200
      Width           =   1095
   End
   Begin MSCommLib.MSComm MSComm1 
      Left            =   3480
      Top             =   2280
      _ExtentX        =   1005
      _ExtentY        =   1005
      _Version        =   393216
      DTREnable       =   -1  'True
   End
   Begin VB.Label Label3 
      Caption         =   "选择串口:"
      Height          =   255
      Left            =   1080
      TabIndex        =   4
      Top             =   480
      Width           =   975
   End
   Begin VB.Label Label5 
      Caption         =   "波特率:"
      Height          =   375
      Left            =   1080
      TabIndex        =   3
      Top             =   1320
      Width           =   735
   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()
 Form1.Visible = False
End Sub


Private Sub Command4_Click()
On Error Resume Next
strset = Combo2.Text + "n" + "8" + "1"  '设置波特率,奇偶校验,数据位和停止位
If Command4.Caption = "打开串口" Then
   Command4.Caption = "关闭串口"
   Combo1.Enabled = False  '设置端口号和波特率不可选
   Combo2.Enabled = False
   'intport = CInt(Right(Trim(combol.Text), 1))
    If Combo1.Text = "COM1" Then
      intport = 1  'intport记录端口号
    Else
      intport = 2  'intport记录端口号
    End If
         Form1.MSComm1.CommPort = intport  '设置端口号
         Form1.MSComm1.PortOpen = Not Form1.MSComm1.PortOpen
         Form1.MSComm1.Settings = strset    '设置端口的波特率,奇偶校验,数据位和停止位属性
         Form1.Visible = False
         If Err Then
           MsgBox Error$, 48 '如果端口被别的程序打开则提示
         End If

Else
   Command4.Caption = "打开串口"
   Combo1.Enabled = True   '设置端口号和波特率为可选
   Combo2.Enabled = True
   Form1.MSComm1.PortOpen = False  '关闭串口
End If
   mnuoen.Checked = MSComm1.PortOpen
   StatusBar.Buttons("transittextfile").Enabled = MSComm1.PortOpen
 If MSComm1.PortOpen Then
  MDIForm1.StatusBar1.Panels(1).Text = "串口设置:" & "COM" & intport & "," & Combo2.Text & ",n,8,1"    '在状态栏中显示口串口的设置
 Else
   MDIForm1.StatusBar1.Panels(1).Text = "串口没有打开"
 End If

End Sub

  

⌨️ 快捷键说明

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