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

📄 二极管控制.frm

📁 利用VB语言来实现二极管的控制
💻 FRM
字号:
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "Mscomm32.ocx"
Begin VB.Form Form1 
   BackColor       =   &H80000013&
   Caption         =   " 二极管控制"
   ClientHeight    =   4155
   ClientLeft      =   5115
   ClientTop       =   3420
   ClientWidth     =   3780
   ForeColor       =   &H00808080&
   LinkMode        =   1  'Source
   LinkTopic       =   "Form1"
   ScaleHeight     =   4155
   ScaleWidth      =   3780
   Begin MSCommLib.MSComm MSComm1 
      Left            =   3120
      Top             =   3000
      _ExtentX        =   1005
      _ExtentY        =   1005
      _Version        =   327681
      DTREnable       =   -1  'True
   End
   Begin VB.Frame Frame2 
      Caption         =   "二极管控制与指示"
      ForeColor       =   &H00C00000&
      Height          =   2295
      Left            =   120
      TabIndex        =   3
      Top             =   120
      Width           =   3495
      Begin VB.CommandButton Command4 
         Caption         =   "开"
         BeginProperty Font 
            Name            =   "楷体_GB2312"
            Size            =   12
            Charset         =   134
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   2640
         TabIndex        =   7
         Top             =   1320
         Width           =   615
      End
      Begin VB.CommandButton Command3 
         Caption         =   "开"
         BeginProperty Font 
            Name            =   "楷体_GB2312"
            Size            =   12
            Charset         =   134
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   1800
         TabIndex        =   6
         Top             =   1320
         Width           =   615
      End
      Begin VB.CommandButton Command2 
         Caption         =   "开"
         BeginProperty Font 
            Name            =   "楷体_GB2312"
            Size            =   12
            Charset         =   134
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   960
         TabIndex        =   5
         Top             =   1320
         Width           =   615
      End
      Begin VB.CommandButton Command1 
         Appearance      =   0  'Flat
         BackColor       =   &H00E38A7D&
         Cancel          =   -1  'True
         Caption         =   "开"
         BeginProperty Font 
            Name            =   "楷体_GB2312"
            Size            =   12
            Charset         =   134
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   120
         MaskColor       =   &H000000FF&
         TabIndex        =   4
         Top             =   1320
         UseMaskColor    =   -1  'True
         Width           =   615
      End
      Begin VB.Label Label1 
         ForeColor       =   &H000000FF&
         Height          =   255
         Left            =   120
         TabIndex        =   15
         Top             =   1920
         Width           =   3255
      End
      Begin VB.Label Label8 
         Caption         =   "4"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   12
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00FF0000&
         Height          =   255
         Left            =   2880
         TabIndex        =   13
         Top             =   360
         Width           =   255
      End
      Begin VB.Label Label7 
         Caption         =   "3"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   12
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00FF0000&
         Height          =   255
         Left            =   2040
         TabIndex        =   12
         Top             =   360
         Width           =   255
      End
      Begin VB.Label Label6 
         Caption         =   "2"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   12
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00FF0000&
         Height          =   255
         Left            =   1200
         TabIndex        =   11
         Top             =   360
         Width           =   255
      End
      Begin VB.Label Label5 
         Caption         =   "1"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   12
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00FF0000&
         Height          =   255
         Left            =   360
         TabIndex        =   10
         Top             =   360
         Width           =   375
      End
      Begin VB.Shape Shape4 
         BackColor       =   &H00808080&
         BackStyle       =   1  'Opaque
         BorderStyle     =   0  'Transparent
         Height          =   375
         Left            =   2760
         Shape           =   3  'Circle
         Top             =   720
         Width           =   375
      End
      Begin VB.Shape Shape3 
         BackColor       =   &H00808080&
         BackStyle       =   1  'Opaque
         BorderStyle     =   0  'Transparent
         Height          =   375
         Left            =   1920
         Shape           =   3  'Circle
         Top             =   720
         Width           =   375
      End
      Begin VB.Shape Shape2 
         BackColor       =   &H00808080&
         BackStyle       =   1  'Opaque
         BorderStyle     =   0  'Transparent
         Height          =   375
         Left            =   1080
         Shape           =   3  'Circle
         Top             =   720
         Width           =   375
      End
      Begin VB.Shape Shape1 
         BackColor       =   &H00808080&
         BackStyle       =   1  'Opaque
         BorderStyle     =   0  'Transparent
         Height          =   375
         Left            =   120
         Shape           =   3  'Circle
         Top             =   720
         Width           =   495
      End
   End
   Begin VB.Frame Frame1 
      Caption         =   "串口初始化"
      ForeColor       =   &H00C00000&
      Height          =   1455
      Left            =   720
      TabIndex        =   0
      Top             =   2520
      Width           =   2055
      Begin VB.ComboBox Combo1 
         BeginProperty DataFormat 
            Type            =   1
            Format          =   "0;(0)"
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   2052
            SubFormatType   =   1
         EndProperty
         ForeColor       =   &H00C00000&
         Height          =   300
         ItemData        =   "二极管控制.frx":0000
         Left            =   1080
         List            =   "二极管控制.frx":0034
         TabIndex        =   14
         Text            =   "1"
         Top             =   240
         Width           =   735
      End
      Begin VB.CommandButton Command5 
         Appearance      =   0  'Flat
         BackColor       =   &H8000000A&
         Caption         =   "关闭"
         BeginProperty Font 
            Name            =   "楷体_GB2312"
            Size            =   12
            Charset         =   134
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   120
         MaskColor       =   &H0000FF00&
         Style           =   1  'Graphical
         TabIndex        =   2
         Top             =   600
         UseMaskColor    =   -1  'True
         Width           =   855
      End
      Begin VB.Label Label4 
         Caption         =   "端口号:"
         BeginProperty Font 
            Name            =   "新宋体"
            Size            =   10.5
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00008000&
         Height          =   255
         Left            =   120
         TabIndex        =   9
         Top             =   240
         Width           =   1095
      End
      Begin VB.Label Label3 
         Caption         =   "串口状态:"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   12
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H000000C0&
         Height          =   255
         Left            =   120
         TabIndex        =   8
         Top             =   1080
         Width           =   1215
      End
      Begin VB.Label Label2 
         Caption         =   "开"
         BeginProperty Font 
            Name            =   "楷体_GB2312"
            Size            =   21.75
            Charset         =   134
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00008000&
         Height          =   495
         Left            =   1320
         TabIndex        =   1
         Top             =   840
         Width           =   495
      End
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False






Private Sub Combo1_Change()
Dim i As Byte
If MSComm1.PortOpen = True Then
  MSComm1.PortOpen = False
  i = 1
Else
  i = 2
End If
MSComm1.CommPort = Combo1.Text
If i = 1 Then
  MSComm1.PortOpen = True
Else
End If
End Sub

Private Sub Combo1_Click()
Dim i As Byte
If MSComm1.PortOpen = True Then
  MSComm1.PortOpen = False
  i = 1
Else
  i = 2
End If
MSComm1.CommPort = Combo1.Text
If i = 1 Then
  MSComm1.PortOpen = True
Else
End If

End Sub


Private Sub Command1_Click() '(第1个二极管)按钮单击事件
If MSComm1.PortOpen = False Then
  Label1.Caption = "您的串口现在是关闭状态,请先打开串口"
Else
  Label1.Caption = ""
  If Shape1.BackColor = &H808080 Then
    Shape1.BackColor = &HC000&
    Command1.Caption = "关"
    MSComm1.Output = "1"
  Else
    Shape1.BackColor = &H808080
    Command1.Caption = "开"
    MSComm1.Output = "2"
  End If
End If

End Sub

Private Sub Command2_Click() '(第2个二极管)按钮单击事件
If MSComm1.PortOpen = False Then
  Label1.Caption = "您的串口现在是关闭状态,请先打开串口"
Else
  Label1.Caption = ""
  If Shape2.BackColor = &H808080 Then
    Shape2.BackColor = &HC000&
    Command2.Caption = "关"
    MSComm1.Output = "3"
  Else
    Shape2.BackColor = &H808080
    Command2.Caption = "开"
    MSComm1.Output = "4"
  End If
End If

End Sub

Private Sub Command3_Click() '(第3个二极管)按钮单击事件
If MSComm1.PortOpen = False Then
  Label1.Caption = "您的串口现在是关闭状态,请先打开串口"
Else
  Label1.Caption = ""
  If Shape3.BackColor = &H808080 Then
    Shape3.BackColor = &H80FF&
    Command3.Caption = "关"
    MSComm1.Output = "5"
  Else
    Shape3.BackColor = &H808080
    Command3.Caption = "开"
    MSComm1.Output = "6"
  End If
End If

End Sub

Private Sub Command4_Click() '(第4个二极管)按钮单击事件
If MSComm1.PortOpen = False Then
  Label1.Caption = "您的串口现在是关闭状态,请先打开串口"
Else
  Label1.Caption = ""
  If Shape4.BackColor = &H808080 Then
    Shape4.BackColor = &HFF0000
    Command4.Caption = "关"
    MSComm1.Output = "7"
  Else
    Shape4.BackColor = &H808080
    Command4.Caption = "开"
    MSComm1.Output = "8"
  End If
End If

End Sub

Private Sub Command6_Click() '(设置串口的端口号)按钮单击事件
If MSComm1.PortOpen = True Then
  MSComm1.PortOpen = False
Else
End If
MSComm1.CommPort = Text2.Text
MSComm1.PortOpen = True

End Sub

Private Sub Form_Load() '初始化
MSComm1.CommPort = Combo1.Text
MSComm1.Settings = "19200,n,8,1"
If MSComm1.PortOpen = True Then
  MSComm1.PortOpen = False
Else
End If
Command5.Caption = "打开"
Label2.Caption = "关"
Label2.ForeColor = &HFF&
End Sub


Private Sub Command5_Click() '(控制串口的开与关)按钮单击事件
If MSComm1.PortOpen = True Then
  Command5.Caption = "打开"
  MSComm1.PortOpen = False
  Label2.Caption = "关"
  Label2.ForeColor = &HFF&
Else
  Command5.Caption = "关闭"
  MSComm1.PortOpen = True
  Label2.Caption = "开"
  Label2.ForeColor = &H8000&
End If

End Sub

⌨️ 快捷键说明

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