469,138 Members | 1,298 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,138 developers. It's quick & easy.

does vb2005 have builtin UnDo feature for apps? or do I have to wr

Hello,

Does vb2005 have a built-in UnDo feature / object for applications so that I
can undo actions like other windows apps? Or do I have to write my own UnDo
routine?

If vb2005 does have a builtin Undo feature / object / command -- how to
implement it? invoke it?

If there is no builtin undo feature - is there a recommended way to write an
undo action? what would this way be?

Thanks,
Rich
Mar 15 '07 #1
4 1398

"Rich" <Ri**@discussions.microsoft.comwrote in message
news:D5**********************************@microsof t.com...
Hello,

Does vb2005 have a built-in UnDo feature / object for applications so that
I
can undo actions like other windows apps? Or do I have to write my own
UnDo
routine?

If vb2005 does have a builtin Undo feature / object / command -- how to
implement it? invoke it?

If there is no builtin undo feature - is there a recommended way to write
an
undo action? what would this way be?

Thanks,
Rich
I have seen code for what you are looking for. Here are the steps.

1. Define a set of actions which can happen that will "Do" things.

2. Each action will have a Do and an UnDo routine

3. Then ensure that all updates (Do's) get executed by a kind of funnel
routine. This routine will both cause the action to be performed and if
that action is performed log the action in a collection somewhere in your
application. The application should be a stack FIFO.

4. Now you could use the CLT-Z hot key to reverse each action. Use a Pop to
get the latest action from the stack, and that Pop will remove it from the
stack.

That is the framework for what you are attempting.

Lloyd Sheen

Mar 15 '07 #2
Thanks for your reply. This sounds kind of interesting, except that the last
time I did anything which involved the "words" stack/push/pop - was in C++
in the classroom environment about 10 years ago.

When you say stack - are you refering to the Heap stack? or are you using
"Stack" metaphorically? As in - I log each action in a collection object or
a datatable or something where for example - a user updates a field in a row
in some table on the database but needs to undo that action - so the app
looks at the last row in the collection datatable where I have stored the
criteria used to update this field and what the value was before the update
and restore the previous value?

My goal is to not re-invent the Undo Wheel if it already exists in VB2005.
If I can use the Heap to reverse an action - that would be great. But if
that isn't what you are refering to, then I was planning on writing my own
undo routine where I store each action as I described above stuff to their
previous states - which would actually be a new action.

If you ARE referring to the Heap, could you refresh my brain on how to push
and pop stuff on the heap?

Thanks,
Rich

"Lloyd Sheen" wrote:
>
"Rich" <Ri**@discussions.microsoft.comwrote in message
news:D5**********************************@microsof t.com...
Hello,

Does vb2005 have a built-in UnDo feature / object for applications so that
I
can undo actions like other windows apps? Or do I have to write my own
UnDo
routine?

If vb2005 does have a builtin Undo feature / object / command -- how to
implement it? invoke it?

If there is no builtin undo feature - is there a recommended way to write
an
undo action? what would this way be?

Thanks,
Rich

I have seen code for what you are looking for. Here are the steps.

1. Define a set of actions which can happen that will "Do" things.

2. Each action will have a Do and an UnDo routine

3. Then ensure that all updates (Do's) get executed by a kind of funnel
routine. This routine will both cause the action to be performed and if
that action is performed log the action in a collection somewhere in your
application. The application should be a stack FIFO.

4. Now you could use the CLT-Z hot key to reverse each action. Use a Pop to
get the latest action from the stack, and that Pop will remove it from the
stack.

That is the framework for what you are attempting.

Lloyd Sheen

Mar 16 '07 #3

"Rich" <Ri**@discussions.microsoft.comwrote in message
news:32**********************************@microsof t.com...
Thanks for your reply. This sounds kind of interesting, except that the
last
time I did anything which involved the "words" stack/push/pop - was in
C++
in the classroom environment about 10 years ago.

When you say stack - are you refering to the Heap stack? or are you using
"Stack" metaphorically? As in - I log each action in a collection object
or
a datatable or something where for example - a user updates a field in a
row
in some table on the database but needs to undo that action - so the app
looks at the last row in the collection datatable where I have stored the
criteria used to update this field and what the value was before the
update
and restore the previous value?

My goal is to not re-invent the Undo Wheel if it already exists in VB2005.
If I can use the Heap to reverse an action - that would be great. But if
that isn't what you are refering to, then I was planning on writing my own
undo routine where I store each action as I described above stuff to their
previous states - which would actually be a new action.

If you ARE referring to the Heap, could you refresh my brain on how to
push
and pop stuff on the heap?

Thanks,
Rich

"Lloyd Sheen" wrote:
>>
"Rich" <Ri**@discussions.microsoft.comwrote in message
news:D5**********************************@microso ft.com...
Hello,

Does vb2005 have a built-in UnDo feature / object for applications so
that
I
can undo actions like other windows apps? Or do I have to write my own
UnDo
routine?

If vb2005 does have a builtin Undo feature / object / command -- how
to
implement it? invoke it?

If there is no builtin undo feature - is there a recommended way to
write
an
undo action? what would this way be?

Thanks,
Rich

I have seen code for what you are looking for. Here are the steps.

1. Define a set of actions which can happen that will "Do" things.

2. Each action will have a Do and an UnDo routine

3. Then ensure that all updates (Do's) get executed by a kind of funnel
routine. This routine will both cause the action to be performed and if
that action is performed log the action in a collection somewhere in your
application. The application should be a stack FIFO.

4. Now you could use the CLT-Z hot key to reverse each action. Use a Pop
to
get the latest action from the stack, and that Pop will remove it from
the
stack.

That is the framework for what you are attempting.

Lloyd Sheen

The Stack I am talking about is a "Collection" class in Dot.Net V2.0. Check
out System.Collections.Generic.Stack(Of T). The 'T' is the type of object
you are storing. If you create a set of Action objects then they should all
inherit from a base class that has the methods defined that you will use
'Do' and UnDo'. Then the declaration for the Stack would be

Dim MyStack as System.Collections.Generic.Stack(Of BaseClassForActions)

Then to add a new action you create the action (after it is succesfully
completed) to the stack with the following code (assuming an class named
ActionAdd has been defined and has a method Do which returns a boolean
indicating the success of the action) :

Dim MyAction as new ActionAdd
MyAction.NewText = 'NewText'
if MyAction.Do then
' action worked
MyStack.Push(MyAction)
end if
Now if you want to handle an UnDo the code would be as follows:

Dim UnDoAction as BaseClassForActions ' Note we use the baseclass so that
all action objects returned from a Pop will have the UnDo method

if MyStack.count 0 then
UnDoAction = MyStack.Pop
UnDoAction.UnDo
end if

This should provide a start for the general framework. The actual action
objects are according to the type of application you have.

Lloyd Sheen

Mar 16 '07 #4
Thanks. This sounds like a little more fun than I was planning on. I will
give this a try on a test app.

"Lloyd Sheen" wrote:
>
"Rich" <Ri**@discussions.microsoft.comwrote in message
news:32**********************************@microsof t.com...
Thanks for your reply. This sounds kind of interesting, except that the
last
time I did anything which involved the "words" stack/push/pop - was in
C++
in the classroom environment about 10 years ago.

When you say stack - are you refering to the Heap stack? or are you using
"Stack" metaphorically? As in - I log each action in a collection object
or
a datatable or something where for example - a user updates a field in a
row
in some table on the database but needs to undo that action - so the app
looks at the last row in the collection datatable where I have stored the
criteria used to update this field and what the value was before the
update
and restore the previous value?

My goal is to not re-invent the Undo Wheel if it already exists in VB2005.
If I can use the Heap to reverse an action - that would be great. But if
that isn't what you are refering to, then I was planning on writing my own
undo routine where I store each action as I described above stuff to their
previous states - which would actually be a new action.

If you ARE referring to the Heap, could you refresh my brain on how to
push
and pop stuff on the heap?

Thanks,
Rich

"Lloyd Sheen" wrote:
>
"Rich" <Ri**@discussions.microsoft.comwrote in message
news:D5**********************************@microsof t.com...
Hello,

Does vb2005 have a built-in UnDo feature / object for applications so
that
I
can undo actions like other windows apps? Or do I have to write my own
UnDo
routine?

If vb2005 does have a builtin Undo feature / object / command -- how
to
implement it? invoke it?

If there is no builtin undo feature - is there a recommended way to
write
an
undo action? what would this way be?

Thanks,
Rich

I have seen code for what you are looking for. Here are the steps.

1. Define a set of actions which can happen that will "Do" things.

2. Each action will have a Do and an UnDo routine

3. Then ensure that all updates (Do's) get executed by a kind of funnel
routine. This routine will both cause the action to be performed and if
that action is performed log the action in a collection somewhere in your
application. The application should be a stack FIFO.

4. Now you could use the CLT-Z hot key to reverse each action. Use a Pop
to
get the latest action from the stack, and that Pop will remove it from
the
stack.

That is the framework for what you are attempting.

Lloyd Sheen


The Stack I am talking about is a "Collection" class in Dot.Net V2.0. Check
out System.Collections.Generic.Stack(Of T). The 'T' is the type of object
you are storing. If you create a set of Action objects then they should all
inherit from a base class that has the methods defined that you will use
'Do' and UnDo'. Then the declaration for the Stack would be

Dim MyStack as System.Collections.Generic.Stack(Of BaseClassForActions)

Then to add a new action you create the action (after it is succesfully
completed) to the stack with the following code (assuming an class named
ActionAdd has been defined and has a method Do which returns a boolean
indicating the success of the action) :

Dim MyAction as new ActionAdd
MyAction.NewText = 'NewText'
if MyAction.Do then
' action worked
MyStack.Push(MyAction)
end if
Now if you want to handle an UnDo the code would be as follows:

Dim UnDoAction as BaseClassForActions ' Note we use the baseclass so that
all action objects returned from a Pop will have the UnDo method

if MyStack.count 0 then
UnDoAction = MyStack.Pop
UnDoAction.UnDo
end if

This should provide a start for the general framework. The actual action
objects are according to the type of application you have.

Lloyd Sheen

Mar 16 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Enigman O'Maly | last post: by
2 posts views Thread by Tony Nelson | last post: by
11 posts views Thread by Mad Joe | last post: by
2 posts views Thread by Omar Abid | last post: by
12 posts views Thread by rdemyan via AccessMonster.com | last post: by
113 posts views Thread by John Nagle | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.