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

📄 例9.frm

📁 在VB5环境下开发的VB程序集,窗体控件源代码.
💻 FRM
字号:
VERSION 5.00
Begin VB.Form FRM7_7_3 
   BackColor       =   &H00C0FFC0&
   Caption         =   "Timer 设计实例2--交通岗红绿灯"
   ClientHeight    =   5220
   ClientLeft      =   375
   ClientTop       =   1260
   ClientWidth     =   8940
   LinkTopic       =   "Form1"
   ScaleHeight     =   5220
   ScaleWidth      =   8940
   Begin VB.Timer Timer5 
      Left            =   7440
      Top             =   1680
   End
   Begin VB.CommandButton Command1 
      Caption         =   "Start"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   18
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   7200
      TabIndex        =   5
      Top             =   2160
      Width           =   1215
   End
   Begin VB.Timer Timer4 
      Left            =   6120
      Top             =   2280
   End
   Begin VB.Timer Timer3 
      Left            =   6120
      Top             =   1560
   End
   Begin VB.Timer Timer2 
      Left            =   6120
      Top             =   840
   End
   Begin VB.Timer Timer1 
      Left            =   6120
      Top             =   120
   End
   Begin VB.PictureBox Picture5 
      AutoSize        =   -1  'True
      Height          =   540
      Left            =   7080
      Picture         =   "例9.frx":0000
      ScaleHeight     =   480
      ScaleWidth      =   480
      TabIndex        =   4
      Top             =   840
      Width           =   540
   End
   Begin VB.PictureBox Picture4 
      AutoSize        =   -1  'True
      Height          =   540
      Left            =   720
      Picture         =   "例9.frx":0442
      ScaleHeight     =   480
      ScaleWidth      =   480
      TabIndex        =   3
      Top             =   240
      Width           =   540
   End
   Begin VB.PictureBox Picture3 
      AutoSize        =   -1  'True
      Height          =   540
      Left            =   720
      Picture         =   "例9.frx":0884
      ScaleHeight     =   480
      ScaleWidth      =   480
      TabIndex        =   2
      Top             =   240
      Width           =   540
   End
   Begin VB.PictureBox Picture2 
      AutoSize        =   -1  'True
      Height          =   540
      Left            =   720
      Picture         =   "例9.frx":0CC6
      ScaleHeight     =   480
      ScaleWidth      =   480
      TabIndex        =   1
      Top             =   240
      Width           =   540
   End
   Begin VB.PictureBox Picture1 
      AutoSize        =   -1  'True
      Height          =   540
      Left            =   720
      Picture         =   "例9.frx":1108
      ScaleHeight     =   480
      ScaleWidth      =   480
      TabIndex        =   0
      Top             =   240
      Width           =   540
   End
   Begin VB.Label Label4 
      BackColor       =   &H0000FF00&
      Caption         =   "问题:汽车速度如何调节?"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   18
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   1200
      TabIndex        =   9
      Top             =   4440
      Width           =   4335
   End
   Begin VB.Label Label3 
      BackColor       =   &H0000FFFF&
      Caption         =   "1、灯的循环靠Timer控件进行控制,用一个控件或4个控件均可。"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   18
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FF00FF&
      Height          =   735
      Left            =   1200
      TabIndex        =   8
      Top             =   2760
      Width           =   6015
   End
   Begin VB.Label Label2 
      BackColor       =   &H000000FF&
      Caption         =   "2、划出红灯区,在红灯区之外汽车运动,在红灯区内依信号灯而定。"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   18
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FF0000&
      Height          =   735
      Left            =   1200
      TabIndex        =   7
      Top             =   3480
      Width           =   6015
   End
   Begin VB.Label Label1 
      BackColor       =   &H0000FF00&
      Caption         =   "解题思路"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   18
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   2400
      TabIndex        =   6
      Top             =   2280
      Width           =   1575
   End
   Begin VB.Line Line1 
      BorderColor     =   &H0000FFFF&
      BorderWidth     =   5
      X1              =   3120
      X2              =   3120
      Y1              =   240
      Y2              =   2160
   End
End
Attribute VB_Name = "FRM7_7_3"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Picture1.Visible = True  'RED
Picture2.Visible = False 'YELLOW
Picture3.Visible = False 'GREEN
Picture4.Visible = False 'YELLOW

Timer1.Enabled = True
Timer2.Enabled = False
Timer3.Enabled = False
Timer4.Enabled = False
Timer5.Enabled = True
End Sub

Private Sub Form_Load()
Picture1.Visible = True  'RED
Picture2.Visible = False 'YELLOW
Picture3.Visible = False 'GREEN
Picture4.Visible = False 'YELLOW
Picture5.Visible = True  'CAR

Timer1.Enabled = False
Timer2.Enabled = False
Timer3.Enabled = False
Timer4.Enabled = False
Timer5.Enabled = False

Timer1.Interval = 2500
Timer2.Interval = 1000
Timer3.Interval = 3000
Timer4.Interval = 1000
Timer5.Interval = 30
End Sub

Private Sub Timer1_Timer()
Picture1.Visible = False  'RED
Picture2.Visible = True 'YELLOW
Picture3.Visible = False 'GREEN
Picture4.Visible = False 'YELLOW

Timer1.Enabled = False
Timer2.Enabled = True
Timer3.Enabled = False
Timer4.Enabled = False
End Sub

Private Sub Timer2_Timer()
Picture1.Visible = False  'RED
Picture2.Visible = False 'YELLOW
Picture3.Visible = True 'GREEN
Picture4.Visible = False 'YELLOW

Timer1.Enabled = False
Timer2.Enabled = False
Timer3.Enabled = True
Timer4.Enabled = False
End Sub

Private Sub Timer3_Timer()
Picture1.Visible = False 'RED
Picture2.Visible = False 'YELLOW
Picture3.Visible = False 'GREEN
Picture4.Visible = True 'YELLOW

Timer1.Enabled = False
Timer2.Enabled = False
Timer3.Enabled = False
Timer4.Enabled = True
End Sub

Private Sub Timer4_Timer()
Picture1.Visible = True  'RED
Picture2.Visible = False 'YELLOW
Picture3.Visible = False 'GREEN
Picture4.Visible = False 'YELLOW

Timer1.Enabled = True
Timer2.Enabled = False
Timer3.Enabled = False
Timer4.Enabled = False
End Sub

Private Sub Timer5_Timer()
If Picture5.Left >= Line1.X1 + 40 Then
Picture5.Left = Picture5.Left - 40
Else
  If Picture5.Left >= Line1.X1 Then
    If Picture3.Visible = True Then
    Picture5.Left = Picture5.Left - 40
    Else
    Picture5.Left = Picture5.Left
    End If
  Else
  Picture5.Left = Picture5.Left - 40
  End If
End If

If Picture5.Left <= FRM7_7_3.Left Then
Picture5.Left = Me.Left + Me.Width
End If
End Sub

⌨️ 快捷键说明

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