I am pretty certain the OP posted something about needing to reset it after
6 presses or something like that. That logic can also be written into the
click handler but roughly 90% of the postings suggest that placing business
logic into an event handler is not a great idea. And if he wants to click
Button2 to have the value reset then what?
I still don't know what he's ultimately trying to do but I will suggest (as
an alternative) that he model his app in a class designed to
handle/process/maintain whatever states his "little machine" needs to keep
track of.
Al@n: You can clearly scatter static variables throughout your UI code...
I'll recommend against it. Have you developed a class before? If you have
then it's time to do it again, if not, it might be a good time to consider
it. Your object will contain all the data related to itself, it can raise
events, etc., etc.
"One Handed Man" <O_************************@BTInternet.com> wrote in
message news:bv**********@sparta.btinternet.com...
Well, Tom is right you could increment a form class level integer and
increment that, but using a static integer in the method is tidier I
think.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Static Dim count As Integer = 0
count += 1
lblCount.Text = count.ToString
End Sub
Regards - OHM
Al@n wrote: Gents
What I'm trying to achieve is a simulation of a controlpanel used in
work-for training purposes.
In pushing a particular button a number of times it will alter the
"display panel" each click event until
interrupted by another button is clicked
I need to retain the number of clicks on the original button to
recommence the display at the point it was interrupted.
I'm sorry if the question seemed silly but am new to this game and
couldn't work out how to achieve my goal.
Thanks for the assistance offered
Al@n
"Tom Leylan" <ge*@iamtiredofspam.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl... "One Handed Man" <O_************************@BTInternet.com> wrote...
No, I dont think it is a trick question. The OP needs a static (
Shared ) integer doesent he/she ?, The problem is that the OP has asked an
innocent question, your mind has told you that there must be more
to it !
I thought the OP needed to keep track of how many times a button on
a form was clicked. Any old integer property declared in the form
will do it I think but I could be wrong.
--
Best Regards - OHM
O_H_M{at}BTInternet{dot}com