• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Visual Basic helps.....

MC

Platinum Member
i never use VB before and now i need help from ATOT!

I need to implement an UNDO function for a VB program, how should i do it? Not just a text box, but all the commands, any help would be great, code would be awesome. 😀
 
Well, for starters, you need a buffer of the previous commands, and possibly the states of the data. You're going to have to decide how big the buffer should be. Considering the amount of work it would take, I'd genuinely be surprised if someone just gave you code to do it. 😉
 
There are a couple of approaches to this. One way is to create a list of all previous states of the data and be able to load up your application with any state of data. Every time data changes, you add another state. You would want to put a limit to the number of Undo states you store.

Another approach is to not track the entire state of the data with every change, but to essentially summarize what it would take to undo/redo any action. So you keep track of a list of action pairs. At any point, you can play these actions forward or backwards and they would modify the current state. You couldn't jump anywhere in the Undo stack you wanted, but most applications don't need this.

I was recently programming a game of Go, and I needed undo functionality. It needs to not only track the positions of all the stones on the board, but other key aspects of the game. I got lazy and just tracked every move that was made, and not an "undo" action. I also didn't track the full game state after every move. If the player wanted to undo a move, I just reset the whole game and played it forward from the beginning until I reached the point before the very last move. This may seem inefficient, but the game is simple enough that even very low end devices could play through 100 moves forward with almost no delay.
 
best way programatically is to add an undo section to each procedure and then call the procedures in reverse order with the undo switch on.
but this will only go so far, you may have to store variable values aswell

eg

Sub dosomestuff(number1 as integer,number2 as integer, undo as boolean)

stuff goes here

End Sub
 
Back
Top