VB中,如何让某一个事件执行十次后返回初始状态

来源:百度知道 编辑:UC知道 时间:2024/05/27 18:28:26
VB中,如何让某一个事件执行十次后返回初始状态
Private Sub Timer1_Timer()
Picture1.Move Picture1.Left + 1000

End Sub
让这个事件,执行十次后。返回初始状态。此事件--当程序运行时。Picture1向程序窗口右侧移动

Private Sub Timer1_Timer()
Static N
Picture1.Move Picture1.Left + 1000
N = N + 1
If N = 10 Then
Picture1.Move Picture1.Left - 1000 * 10
Timer1.Enabled = False
End If
End Sub

没有弄明白你那个要求 我弄了一个点击按钮 让图片左右摇摆的程序 你看下吧 或许对你有所帮助
-
一个图片控件一个按钮
---
代码
--
Public Class Form1
Dim x As String = "右"

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Timer1.Enabled = Not Me.Timer1.Enabled
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If Me.PictureBox1.Left = 0 Then
x = "右"
End If
If Me.PictureBox1.Left = Me.Width - Me.PictureBox1.Width Then
x = "左"
End If
If x = "右" Then
Me.Pi