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

📄 rocket.frm

📁 rocket 演示了控制图片移动的方法
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmrocket 
   Appearance      =   0  'Flat
   BackColor       =   &H00FF0000&
   Caption         =   "Blast Off"
   ClientHeight    =   4950
   ClientLeft      =   2115
   ClientTop       =   1605
   ClientWidth     =   4020
   BeginProperty Font 
      Name            =   "MS Sans Serif"
      Size            =   8.25
      Charset         =   0
      Weight          =   700
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   ForeColor       =   &H80000008&
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   PaletteMode     =   1  'UseZOrder
   ScaleHeight     =   4950
   ScaleWidth      =   4020
   Begin VB.CommandButton cmdQuit 
      Caption         =   "&QUIT"
      Height          =   495
      Left            =   3240
      TabIndex        =   5
      Top             =   4320
      Width           =   735
   End
   Begin VB.CommandButton cmdRight 
      Caption         =   "RIGHT"
      Height          =   495
      Left            =   120
      TabIndex        =   4
      Top             =   1560
      Width           =   1215
   End
   Begin VB.CommandButton cmdLeft 
      Caption         =   "LEFT"
      Height          =   495
      Left            =   120
      TabIndex        =   3
      Top             =   840
      Width           =   1215
   End
   Begin VB.CommandButton cmdDown 
      Caption         =   "DOWN"
      Height          =   495
      Left            =   2640
      TabIndex        =   2
      Top             =   1560
      Width           =   1215
   End
   Begin VB.CommandButton cmdUp 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      Caption         =   "UP"
      Height          =   495
      Left            =   2640
      TabIndex        =   1
      Top             =   840
      Width           =   1215
   End
   Begin VB.PictureBox picRocket 
      Appearance      =   0  'Flat
      AutoRedraw      =   -1  'True
      AutoSize        =   -1  'True
      BackColor       =   &H80000005&
      DrawStyle       =   5  'Transparent
      ForeColor       =   &H80000008&
      Height          =   510
      Left            =   1680
      Picture         =   "ROCKET.frx":0000
      ScaleHeight     =   480
      ScaleWidth      =   480
      TabIndex        =   0
      Top             =   3600
      Width           =   510
   End
   Begin VB.Image imgLogo 
      Height          =   480
      Left            =   120
      Picture         =   "ROCKET.frx":030A
      Top             =   4320
      Width           =   480
   End
   Begin VB.Label lblAuthor 
      Alignment       =   2  'Center
      BackColor       =   &H000000FF&
      Caption         =   "   WRITTEN BY    ED HAMMOND "
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FFFFFF&
      Height          =   495
      Left            =   960
      TabIndex        =   7
      Top             =   4320
      Width           =   1695
   End
   Begin VB.Line linQuitLeft 
      BorderWidth     =   5
      X1              =   3120
      X2              =   3120
      Y1              =   4200
      Y2              =   4920
   End
   Begin VB.Line linQuitTop 
      BorderWidth     =   5
      X1              =   3120
      X2              =   3960
      Y1              =   4200
      Y2              =   4200
   End
   Begin VB.Label lblInstuctions 
      BackColor       =   &H000000FF&
      Caption         =   "  Press the buttons with the left mouse key      to move the rocketship."
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FFFFFF&
      Height          =   495
      Left            =   120
      TabIndex        =   6
      Top             =   120
      Width           =   3735
   End
End
Attribute VB_Name = "frmrocket"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'控制图片框Image的移动的例子
Dim Myup As Integer
Dim Mydown As Integer
Dim Myleft As Integer
Dim Myright As Integer
Dim Mymove As String
Private Sub cmdDown_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = 1 Then
        Mydown = True
        Mymove = down
        Mypicturemove
    End If
End Sub

Private Sub cmdDown_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = 1 Then
        Mydown = False
        Mypicturemove
    End If
End Sub

Private Sub cmdUp_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = 1 Then
        Myup = True
        Mymove = up
        Mypicturemove
    End If
End Sub

Private Sub cmdUp_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = 1 Then
        Myup = False
        Mypicturemove
    End If
End Sub

Private Sub cmdLeft_Click()
    picRocket.Left = picRocket.Left - 50
End Sub

Private Sub cmdQuit_Click()

    Unload Me
End Sub

Private Sub cmdRight_Click()
    picRocket.Left = picRocket.Left + 50
End Sub

Private Sub Form_Load()
'This centers the form on the screen
    frmrocket.Top = (Screen.Height - frmrocket.Height) / 2
    frmrocket.Left = (Screen.Width - frmrocket.Width) / 2
End Sub

Public Sub Mypicturemove()
    If Mymove = up Then
            Do While Myup = True
                DoEvents
                picRocket.Top = picRocket.Top - 1
            Loop
    End If
    
    If Mymove = down Then
            Do While Mydown = True
                DoEvents
                picRocket.Top = picRocket.Top + 1
            Loop
    End If
    
    'ElseIf Mymove = lleft Then
            'Do While Myleft = True
                'DoEvents
                'picRocket.Left = picRocket.Left - 1
            'Loop
        
    'ElseIf Mymove = rright Then
            'Do While Myright = True
                'DoEvents
                'picRocket.Left = picRocket.Left + 1
            'Loop
   'End If
'*************************************************
    Select Case Mymove
        Case up
            Do While Myup = True
                DoEvents
                picRocket.Top = picRocket.Top - 1
            Loop
        Case down
            Do While Mydown = True
                DoEvents
                picRocket.Top = picRocket.Top + 1
            Loop
        
        'Case lleft
            'Do While Myleft = True
                'DoEvents
                'picRocket.Left = picRocket.Left - 1
            'Loop
        
        'Case rright
            'Do While Myright = True
                'DoEvents
                'picRocket.Left = picRocket.Left + 1
            'Loop
   End Select
End Sub

'*************************************************

⌨️ 快捷键说明

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