0

Hi ,
I already created a button "enjoy button" that i want to move in a form when the "timer start button" is clicked.
how do link the timer to the
"timer start button" and make it move?

this is what i tried so far..then am blank
first


Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Me.xTimer.Enabled = False
xTimer.Interval = 10

DX = 1
xDXTextBox.Text = DX

DY = 1
xDYTextBox.Text = DY


Counter = 1000
xCounterTextBox.Text = Counter

X = 216
Y = 135

Me.xButtonLabel.Text = "Button(" & X & ", " & Y & ")"

then

Private Sub TimeStartButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles xTimeStartButton.Click

Me.xTimer.Enabled = True

4
Contributors
9
Replies
11
Views
8 Years
Discussion Span
Last Post by bondgirl21
0

on timer tick event
- make randomize function to get new X and Y,so your button always get new location to moving every timer tick.

0

how do i randomize?
can u give me an example?

i got it...i used

Me.xButtonLabel.Text = "Button(" & xEnjoyButton.Location.X.ToString & ", " & xEnjoyButton.Location.Y.ToString & ")

but now i want to make the timer stop when i click the timer start button and the button stop moving aswell..how do i do that?

0

Why would you want the timer to stop when you press the button to start the timer? lol. If you put the code to move the button in the timer_tick event, as you should have already, you just need to stop the timer like this.

Private Sub TimeStartButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles xTimeStartButton.Click

xTimer.Stop()

End Sub
0

Why would you want the timer to stop when you press the button to start the timer? lol. If you put the code to move the button in the timer_tick event, as you should have already, you just need to stop the timer like this.

Private Sub TimeStartButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles xTimeStartButton.Click

Me.xTimer.Stop()

End Sub

I want the timer to switch on and off when i click the "timer start button"..i just want to have one button, that's why i didnt create "timer stop button"....

0

but now i want to use the button "start time button" as a switch to turn off and on the ticker if click...first it turns it on then off, etc.

This is what i got to start it

Private Sub TimeStartButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles xTimeStartButton.Click

        If Me.xTimeStartButton.Enabled = True Then
            Me.xTimer.Start()
        End If
0

Ok, then try this in the button click:

If xTimer.Enabled = True Then
            xTimer.Stop()
            xTimer.Enabled = False
        ElseIf Timer1.Enabled = False Then
            xTimer.Enabled = True
            xTimer.Start()
        End If

P.S. You don't need to keep using all those "Me"s

0

Ok, then try this in the button click:

If xTimer.Enabled = True Then
            xTimer.Stop()
            xTimer.Enabled = False
        ElseIf Timer1.Enabled = False Then
            xTimer.Enabled = True
            xTimer.Start()
        End If

P.S. You don't need to keep using all those "Me"s

THanks it worked....oh i didn't know, i thought it was important?

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.