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

xTimer.Start

then

You should use xTimer.Tick event to move your button.

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.

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

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?

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

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"....

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

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

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?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.