vb6中的图像变换

vb6中的图像变换,vb6,Vb6,我试图从pdf文件中执行此脚本。如果单击,目标图像应更改为爆炸图像,但目标图像不会更改为站立图像。请帮助 Option Explicit Dim fiPlayersScore As Integer Dim fiNumberofMisses As Integer Dim fbTargetHit As Boolean Private Sub Form_Load() Randomize imgTarget.Enabled = False imgTarget.Visible = False cmdSt

我试图从pdf文件中执行此脚本。如果单击,目标图像应更改为爆炸图像,但目标图像不会更改为站立图像。请帮助

Option Explicit

Dim fiPlayersScore As Integer
Dim fiNumberofMisses As Integer
Dim fbTargetHit As Boolean
Private Sub Form_Load()
Randomize
imgTarget.Enabled = False
imgTarget.Visible = False
cmdStop.Enabled = False
lblGameOver.Visible = False
lblGameOver.Enabled = False
End Sub
Private Sub cmdStart_Click()
Dim lsUserResponse As String
Dim lbResponse As Boolean

lsUserResponse = InputBox("Enter a level from 1 to 3." & _
(Chr(13)) & "" & (Chr(13)) & "1 being  the Easiest and 3 being the " & _
"Hardest.", "Level Select", "1")
lbResponse = False
If lsUserResponse = "1" Then
Timer1.Interval = 1500
lbResponse = True
ElseIf lsUserResponse = "2" Then
Timer1.Interval = 1000
lbResponse = True
ElseIf lsUserResponse = "3" Then
Timer1.Interval = 750
lbResponse = True
Else
MsgBox ("Game Not Started.")
lbResponse = False
End If
If lbResponse = True Then
cmdStart.Enabled = False
imgTarget.Picture = imgStanding.Picture 

frmMain.MousePointer = 5
fbTargetHit = False
Load_Sounds
cmdStop.Enabled = True
fiPlayersScore = 0
fiNumberofMisses = 0
lblScore.Caption = fiPlayersScore
lblMisses.Caption = fiNumberofMisses
Timer1.Enabled = True
lblGameOver.Visible = False
lblGameOver.Enabled = False
End If
End Sub

Private Sub cmdStop_Click()
Unload_Sounds
frmMain.MousePointer = vbNormal
Timer1.Enabled = False
imgTarget.Enabled = False
imgTarget.Visible = False
cmdStart.Enabled = True
cmdStop.Enabled = False
cmdStart.SetFocus
lblGameOver.Visible = True
lblGameOver.Enabled = True
End Sub

Private Sub Form_Click()
MMControl1.Command = "Play"
MMControl1.Command = "Prev"
fiNumberofMisses = fiNumberofMisses + 1
lblMisses.Caption = fiNumberofMisses
If CheckForLoose = True Then
cmdStop_Click
lblMisses.Caption = fiNumberofMisses
Exit Sub
End If
End Sub

Private Sub imgTarget_Click()
MMControl2.Command = "Play"
MMControl2.Command = "Prev"
Timer1.Enabled = False
imgTarget.Picture = imgExplode.Picture '**I AM STUCK HERE**
pauseProgram

fiPlayersScore = fiPlayersScore + 1
Timer1.Enabled = True
If CheckForWin = True Then
cmdStop_Click
lblScore.Caption = fiPlayersScore
Exit Sub
End If
lblScore.Caption = fiPlayersScore
fbTargetHit = True
imgStanding.Enabled = False
imgTarget.Visible = False
imgTarget.Enabled = False
Timer1.Enabled = True
End Sub
Public Sub Load_Sounds()
'Set initial property values for blaster sound
MMControl1.Notify = False
MMControl1.Wait = True
MMControl1.Shareable = False
MMControl1.DeviceType = "WaveAudio"
MMControl1.FileName = _
"C:\Temp\Sounds\Blaster_1.wav"
'Open the media device
 MMControl1.Command = "Open"

 Private Sub Timer1_Timer()
 Dim liRandomLeft As Integer
 Dim liRandomTop As Integer
 imgTarget.Visible = True
 If fbTargetHit = True Then
 fbTargetHit = False
 imgTarget.Picture = imgStanding.Picture
 End If
 liRandomLeft = (6120 * Rnd)
 liRandomTop = (4680 * Rnd)
 imgTarget.Left = liRandomLeft
 imgTarget.Top = liRandomTop
 imgTarget.Enabled = True
 imgTarget.Visible = True
 End Sub

 Public Function CheckForWin() As Boolean
 CheckForWin = False
 If fiPlayersScore = 5 Then
 CheckForWin = True
 lblGameOver.Caption = "You Win.Game Over"
 End If
 End Function
 Public Function CheckForLoose() As Boolean
 CheckForLoose = False
 If fiNumberofMisses = 5 Then
 CheckForLoose = True
 lblGameOver.Caption = "You Loose.Game Over"
 End If
 End Function

Private Sub Form_QueryUnload(Cancel As Integer, _
UnloadMode As Integer)
Unload_Sounds
End Sub
Public Sub Unload_Sounds()
MMControl1.Command = "Close"
MMControl2.Command = "Close"
End Sub
Public Sub pauseProgram()
Dim currentTime
Dim newTime
currentTime = Second(Time)
newTime = Second(Time)
Do Until Abs(newTime - currentTime) >= 1
newTime = Second(Time)
Loop
End Sub
编辑:

imgTarget.Picture = imgExplode.Picture
imgTarget.Refresh 
注:

将比

imgTarget.Picture = imgExplode.Picture
imgTarget.Refresh

如果imgExplode将在imgTarget的生存期内出现(第一个命令复制映像,Set命令引用映像).

这是用于多个图像并随时间自动加载为什么不只是在单击事件时从图像列表加载新图像。我找不到图像列表控件要将图像列表控件添加到VB项目中,请单击项目|组件,并选中Microsoft Windows Common Controls旁边的复选框感谢在google上搜索后,我得到了如何添加imagelist控件。在运行脚本时,错误消息是m_index变量未定义。因此,我在start Private m_index中添加了整数Private m_NumImages As Integer,并在Private Sub imgTarget_Click()中添加了m_Index=((m_Index+1)Mod m_NumImages)+1 imgTarget.Picture=ImageList1.ListImages(m_Index)。Picture但结果与之前相同抱歉,克里斯回答问题稍微晚了一点
imgTarget.Picture = imgExplode.Picture
imgTarget.Refresh