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

📄 frmball.frm

📁 河北工业大学大一至大二学期
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmBall 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Ball Go!"
   ClientHeight    =   7515
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   8850
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   7515
   ScaleWidth      =   8850
   StartUpPosition =   3  'Windows Default
   Begin VB.HScrollBar HScroll2 
      Height          =   255
      Left            =   6000
      Max             =   100
      Min             =   1
      TabIndex        =   7
      Top             =   3600
      Value           =   1
      Width           =   2175
   End
   Begin VB.HScrollBar HScroll1 
      Height          =   255
      Left            =   6000
      Max             =   15
      Min             =   1
      TabIndex        =   6
      Top             =   2880
      Value           =   1
      Width           =   2175
   End
   Begin VB.Timer tmrBallGo 
      Enabled         =   0   'False
      Interval        =   10
      Left            =   6360
      Top             =   2040
   End
   Begin VB.CommandButton cmdRndPos 
      Caption         =   "随机放球"
      Height          =   495
      Left            =   6720
      TabIndex        =   5
      Top             =   4320
      Width           =   1575
   End
   Begin VB.CommandButton cmdExit 
      Caption         =   "退 出"
      Height          =   495
      Left            =   6720
      TabIndex        =   3
      Top             =   5760
      Width           =   1575
   End
   Begin VB.CommandButton cmdStart 
      Caption         =   "开  始"
      Height          =   495
      Left            =   6720
      TabIndex        =   2
      Top             =   5040
      Width           =   1575
   End
   Begin VB.PictureBox picBack 
      Appearance      =   0  'Flat
      BackColor       =   &H00000000&
      BorderStyle     =   0  'None
      ForeColor       =   &H80000008&
      Height          =   6495
      Left            =   360
      ScaleHeight     =   6495
      ScaleWidth      =   5535
      TabIndex        =   0
      Top             =   480
      Width           =   5535
      Begin VB.Label ball 
         Alignment       =   2  'Center
         Appearance      =   0  'Flat
         BackColor       =   &H0000FFFF&
         BorderStyle     =   1  'Fixed Single
         Caption         =   "◎"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   11.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   255
         Left            =   1320
         TabIndex        =   1
         Top             =   3840
         Width           =   255
      End
   End
   Begin VB.CommandButton cmdStop 
      Caption         =   "停 止"
      Height          =   495
      Left            =   6720
      TabIndex        =   4
      Top             =   5040
      Width           =   1575
   End
   Begin VB.Label lblTime 
      Caption         =   "0"
      Height          =   255
      Left            =   8280
      TabIndex        =   11
      Top             =   3600
      Width           =   495
   End
   Begin VB.Label lblspd 
      Caption         =   "0"
      Height          =   255
      Left            =   8280
      TabIndex        =   10
      Top             =   2880
      Width           =   495
   End
   Begin VB.Label Label2 
      Caption         =   "计时器的间隔时间(毫秒)"
      Height          =   255
      Left            =   6000
      TabIndex        =   9
      Top             =   3240
      Width           =   2415
   End
   Begin VB.Label Label1 
      Caption         =   "小球每次滚动的距离(像素)"
      Height          =   255
      Left            =   6000
      TabIndex        =   8
      Top             =   2520
      Width           =   2415
   End
End
Attribute VB_Name = "frmBall"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim dX As Long, dY As Long
Dim Spd  As Long

Private Sub cmdExit_Click()
Unload Me
End Sub

Private Sub cmdRndPos_Click()
ball.Left = Rnd * (picBack.ScaleWidth - ball.Width)
ball.Top = Rnd * (picBack.ScaleHeight - ball.Height)
End Sub

Private Sub cmdStart_Click()
tmrBallGo.Enabled = True
cmdStart.Visible = False
End Sub

Private Sub cmdStop_Click()
tmrBallGo.Enabled = False
cmdStart.Visible = True
End Sub

Private Sub Form_Load()
Randomize
Spd = 3
ball.Left = Rnd * (picBack.ScaleWidth - ball.Width)
ball.Top = Rnd * (picBack.ScaleHeight - ball.Height)
dX = 15 * Spd
dY = 15 * Spd
HScroll2.Value = tmrBallGo.Interval
HScroll1.Value = Spd
End Sub

Private Sub HScroll2_Change()
Dim a As Long
a = HScroll2.Value
lblTime.Caption = a
tmrBallGo.Interval = a
End Sub

Private Sub HScroll2_Scroll()
Dim a As Long
a = HScroll2.Value
lblTime.Caption = a
tmrBallGo.Interval = a
End Sub
Private Sub HScroll1_Change()
lblspd.Caption = HScroll1.Value
Spd = HScroll1.Value
dX = Sgn(dX) * 15 * Spd
dY = Sgn(dY) * 15 * Spd
End Sub

Private Sub HScroll1_Scroll()
lblspd.Caption = HScroll1.Value
Spd = HScroll1.Value
dX = Sgn(dX) * 15 * Spd
dY = Sgn(dY) * 15 * Spd
End Sub

Private Sub tmrBallGo_Timer()
ball.Left = ball.Left + dX
ball.Top = ball.Top + dY
If ball.Left < 0 Then ball.Left = -ball.Left: dX = -dX
If ball.Top < 0 Then ball.Top = -ball.Top: dY = -dY
If ball.Left > picBack.ScaleWidth - ball.Width Then
    ball.Left = 2 * picBack.ScaleWidth - 2 * ball.Width - ball.Left: dX = -dX
End If
If ball.Top > picBack.ScaleHeight - ball.Height Then
    ball.Top = 2 * picBack.ScaleHeight - 2 * ball.Height - ball.Top: dY = -dY
End If

End Sub

⌨️ 快捷键说明

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