Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > how to make an undo button?


Reply
 
Thread Tools Display Modes
  #1  
Old 05-14-2005, 01:20 AM
Dr_Colossos's Avatar
Dr_Colossos Dr_Colossos is offline
Centurion
 
Join Date: Apr 2004
Posts: 117
Default 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.
Reply With Quote
  #2  
Old 05-14-2005, 02:07 AM
stevo stevo is offline
Senior Contributor

* Expert *
 
Join Date: May 2004
Location: Manchester, England.
Posts: 1,254
Default

it will be the same code for adding one to the label but you will be taking one away.
Reply With Quote
  #3  
Old 05-14-2005, 03:37 AM
dan_e6's Avatar
dan_e6 dan_e6 is offline
Contributor
 
Join Date: Mar 2004
Posts: 552
Default

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.
Reply With Quote
  #4  
Old 05-14-2005, 03:48 AM
stevo stevo is offline
Senior Contributor

* Expert *
 
Join Date: May 2004
Location: Manchester, England.
Posts: 1,254
Default

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...
Reply With Quote
  #5  
Old 05-14-2005, 04:22 AM
William_Cain's Avatar
William_Cain William_Cain is offline
Junior Contributor
 
Join Date: Jul 2004
Location: Norway
Posts: 318
Default

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...
Reply With Quote
  #6  
Old 05-14-2005, 06:19 AM
Dr_Colossos's Avatar
Dr_Colossos Dr_Colossos is offline
Centurion
 
Join Date: Apr 2004
Posts: 117
Default

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.
Reply With Quote
  #7  
Old 05-14-2005, 07:34 AM
William_Cain's Avatar
William_Cain William_Cain is offline
Junior Contributor
 
Join Date: Jul 2004
Location: Norway
Posts: 318
Default

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.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->