Creating a moving button in vb 2005 Help

Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Feb 2009
Posts: 19
Reputation: bondgirl21 is an unknown quantity at this point 
Solved Threads: 0
bondgirl21 bondgirl21 is offline Offline
Newbie Poster

Creating a moving button in vb 2005 Help

 
0
  #1
Mar 15th, 2009
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
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 51
Reputation: martonx is an unknown quantity at this point 
Solved Threads: 8
martonx martonx is offline Offline
Junior Poster in Training

Re: Creating a moving button in vb 2005 Help

 
0
  #2
Mar 15th, 2009
xTimer.Start

then

You should use xTimer.Tick event to move your button.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 2,641
Reputation: Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light 
Solved Threads: 245
Jx_Man's Avatar
Jx_Man Jx_Man is offline Offline
Posting Maven

Re: Creating a moving button in vb 2005 Help

 
0
  #3
Mar 15th, 2009
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.
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 19
Reputation: bondgirl21 is an unknown quantity at this point 
Solved Threads: 0
bondgirl21 bondgirl21 is offline Offline
Newbie Poster

Re: Creating a moving button in vb 2005 Help

 
0
  #4
Mar 15th, 2009
how do i randomize?
can u give me an example?
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 19
Reputation: bondgirl21 is an unknown quantity at this point 
Solved Threads: 0
bondgirl21 bondgirl21 is offline Offline
Newbie Poster

Re: Creating a moving button in vb 2005 Help

 
0
  #5
Mar 15th, 2009
Originally Posted by bondgirl21 View Post
how do i randomize?
can u give me an example?
i got it...i used

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

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?
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 44
Reputation: crazyhorse09 is an unknown quantity at this point 
Solved Threads: 4
crazyhorse09 crazyhorse09 is offline Offline
Light Poster

Re: Creating a moving button in vb 2005 Help

 
0
  #6
Mar 15th, 2009
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.

  1. Private Sub TimeStartButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles xTimeStartButton.Click
  2.  
  3. xTimer.Stop()
  4.  
  5. End Sub
Last edited by crazyhorse09; Mar 15th, 2009 at 7:25 pm.
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 19
Reputation: bondgirl21 is an unknown quantity at this point 
Solved Threads: 0
bondgirl21 bondgirl21 is offline Offline
Newbie Poster

Re: Creating a moving button in vb 2005 Help

 
0
  #7
Mar 15th, 2009
Originally Posted by crazyhorse09 View Post
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.

  1. Private Sub TimeStartButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles xTimeStartButton.Click
  2.  
  3. Me.xTimer.Stop()
  4.  
  5. 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"....
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 19
Reputation: bondgirl21 is an unknown quantity at this point 
Solved Threads: 0
bondgirl21 bondgirl21 is offline Offline
Newbie Poster

Re: Creating a moving button in vb 2005 Help

 
0
  #8
Mar 15th, 2009
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
  1. Private Sub TimeStartButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles xTimeStartButton.Click
  2.  
  3. If Me.xTimeStartButton.Enabled = True Then
  4. Me.xTimer.Start()
  5. End If
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 44
Reputation: crazyhorse09 is an unknown quantity at this point 
Solved Threads: 4
crazyhorse09 crazyhorse09 is offline Offline
Light Poster

Re: Creating a moving button in vb 2005 Help

 
0
  #9
Mar 15th, 2009
Ok, then try this in the button click:

  1. If xTimer.Enabled = True Then
  2. xTimer.Stop()
  3. xTimer.Enabled = False
  4. ElseIf Timer1.Enabled = False Then
  5. xTimer.Enabled = True
  6. xTimer.Start()
  7. End If

P.S. You don't need to keep using all those "Me"s
Last edited by crazyhorse09; Mar 15th, 2009 at 7:45 pm.
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 19
Reputation: bondgirl21 is an unknown quantity at this point 
Solved Threads: 0
bondgirl21 bondgirl21 is offline Offline
Newbie Poster

Re: Creating a moving button in vb 2005 Help

 
0
  #10
Mar 15th, 2009
Originally Posted by crazyhorse09 View Post
Ok, then try this in the button click:

  1. If xTimer.Enabled = True Then
  2. xTimer.Stop()
  3. xTimer.Enabled = False
  4. ElseIf Timer1.Enabled = False Then
  5. xTimer.Enabled = True
  6. xTimer.Start()
  7. 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?
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the VB.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC