【发布时间】:2018-04-25 13:15:54
【问题描述】:
我正在尝试使用 VBA 在 Excel 中移动一组图片,这很好,但我希望用户可以看到图片是如何移动的。
这是一个小游戏,一场“赛马”。
这是我移动马匹的代码。
Sub TrackProgress()
Dim Tracks() As GroupObject
Dim Agents(), HorseCount As Integer
Dim AgentCount As Integer
Dim TrackCount As Integer
Dim Progress As Double
Dim MaxPx As Double
AgentCount = Sheets("Config").Range("O5").Value
TrackCount = Round(AgentCount / HorsesPerTrack, 0)
ReDim Tracks(1 To TrackCount)
ReDim Agents(1 To AgentCount)
MaxPx = Sheets("Config").Range("O15").Value
Sheets("HorseRaceTrack").Select
For i = 6 To Sheets("Config").Cells(Rows.Count, 5).End(xlUp).Row
If Sheets("Config").Cells(i, 4).Value = "Active" Then
Agents(i - 5) = Sheets("Config").Cells(i, 5).Value
End If
Next i
For i = 1 To AgentCount
If Not IsError(Sheets("Config").Cells(i + 5, 7).Value) Then
Progress = Sheets("Config").Cells(i + 5, 7).Value
Do Until Sheets("HorseRaceTrack").Shapes("Horse_" & Agents(i)).Left >= (MaxPx * Progress)
Sheets("HorseRaceTrack").Shapes("Horse_" & Agents(i)).IncrementLeft 1.3636220472
'Sleep 1000 ' Pferd beweg sich nicht flüssig....
Loop
Else
GoTo NextOne
End If
NextOne:
Next i
End Sub
我已经尝试使用“睡眠 500”,但屏幕也卡住了
感谢您的帮助!
【问题讨论】:
-
不确定您的问题是什么。你的问题是形状不动吗?或者您的代码正在抛出错误消息?或
screen is freezing?还是两者的组合?
标签: excel vba move shape visible