关于VB的shape初始位置的问题

来源:百度知道 编辑:UC知道 时间:2024/07/02 10:36:56
我做一个用TIMER使shape运动的程序, 窗体的长和宽是不确定的,但是shape一定要从左下角移动到右上角,然后就停止 这个是我写的程序,不过总是运行错误.各位帮忙看下哪里错了啊

Const steps As Integer = 40
Dim Counter As Integer

Private Sub Form_Load()

tmrTest.Interval = 500
tmrTest.Enabled = True

End Sub

Private Sub tmrTest_Timer()

Counter = Counter + 1
shpBall(0, Form1.Height) = shpBall((Counter / steps) * Width, Height-(Counter / steps) * Height)

If Counter = steps Then
tmrTest.Enabled = False
End If
End Sub
检测的错误说是"编译错误:错误的参数号或无效的属性赋值"
不过我还是检查不出来啊~

Const steps As Integer = 40
Dim Counter As Integer

Private Sub Form_Load()

tmrTest.Interval = 500
tmrTest.Enabled = True

End Sub

Private Sub tmrTest_Timer()

Counter = Counter + 1
shpBall.Left = (Counter / steps) * Width
shpBall.Top = Height - (Counter / steps) * Height

If Counter = steps Then
tmrTest.Enabled = False
End If
End Sub
你要想移动shape就用他的left和top变化让他的位置移动

Dim Counter As Integer '移动计数
Const moveCounter As Integer = 30 '总移动次数
Dim Wsteps As Long '横向步长
Dim Hsteps As Long '纵向步长

Private Sub Form_Resize() '只要变更窗体大小,就开始一次移动过程
tmrTest.Interval = 50
tmrTest.Enabled = True
shpBall.Move 0, Me.ScaleHeight - shpBall.Height '移动shp到窗体左下角,做初始准备
Wsteps = Int((Me.ScaleWidth - shpBall.Width) / moveCounter) '计算步长
Hsteps = -Int((Me.ScaleHeight - shpBall.Height) / moveCounter)
End Sub

Private Su