 |

05-14-2005, 01:20 AM
|
 |
Centurion
|
|
Join Date: Apr 2004
Posts: 117
|
|
how to make an undo button?
|
I have Label (Label1) and a button (command1)
The caption for label1 is "0"
When I click the button the label will add "1" each time I press the button...
So the labels continues 1, 2, 3, 4, 5, ... and so on...
Now let's say that I have reached to number 21 and I regret that last click.
How can I create an undo button? Let's say we create another button (command2) who should do the trick.
|
|

05-14-2005, 02:07 AM
|
|
Senior Contributor
* Expert *
|
|
Join Date: May 2004
Location: Manchester, England.
Posts: 1,254
|
|
|
it will be the same code for adding one to the label but you will be taking one away.
|
|

05-14-2005, 03:37 AM
|
 |
Contributor
|
|
Join Date: Mar 2004
Posts: 552
|
|
Quote:
|
Originally Posted by stevo
it will be the same code for adding one to the label but you will be taking one away.
|
that will only work if the numbers are done in sequence. what if he wants text? or random numbers?. i think you would have to store the information/numbers in some sort of variable as the user types them, not sure.
|
|

05-14-2005, 03:48 AM
|
|
Senior Contributor
* Expert *
|
|
Join Date: May 2004
Location: Manchester, England.
Posts: 1,254
|
|
in the case of random numbers or different text then yes you would need a variable to hold the caption but
Quote:
|
Originally Posted by Dr_Colossos
When I click the button the label will add "1" each time I press the button...
So the labels continues 1, 2, 3, 4, 5, ... and so on...
|
|
|

05-14-2005, 04:22 AM
|
 |
Junior Contributor
|
|
Join Date: Jul 2004
Location: Norway
Posts: 318
|
|
|
If you want a "real" undo button, you could create a class with the info a single undo step needs, and put each undo step into a collection. That's what I do, and it works like a charm.
However, in this case, it seems like you can just decrease the value in the box by one...
|
|

05-14-2005, 06:19 AM
|
 |
Centurion
|
|
Join Date: Apr 2004
Posts: 117
|
|
|
I thank you all for your help!
I just ran into another problem...
I dont want the label to decrease so low that it turns into -1, -2 etc...
|
Last edited by Dr_Colossos; 05-14-2005 at 06:24 AM.
|

05-14-2005, 07:34 AM
|
 |
Junior Contributor
|
|
Join Date: Jul 2004
Location: Norway
Posts: 318
|
|
Then simply put an if...
Code:
If value > 0 Then
value = value - 1
End If
You should really put your fantasy to a little more use here.
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|