pass variable on eventclick

brianmac

Member
Joined
Jul 21, 2011
Messages
7
Programming Experience
Beginner
I have a grid of NumericUPDown fields. When a value is changed, I want the page to update a label at the bottom of a column - its a total line. Everything works, when the page is updated(a button click), but I want it to update real time. as they are changing the updown value...

My question, and I have searched and couldn't find it, how do I pass a variable to an eventclick subroutine? Or make the variable a global variable, so it will work in the eventclick subroutine...

Sorry for the newbie questions...


Thanks,
Brian
 
well you could use a timer to update in real time set intervals or something like this...

A delay sub...

VB.NET:
[COLOR=blue]Sub[/COLOR] Delay([COLOR=blue]ByVal[/COLOR] dblSecs [COLOR=blue]As[/COLOR] [COLOR=blue]Double[/COLOR])         
[COLOR=blue]Const[/COLOR] OneSec [COLOR=blue]As[/COLOR] [COLOR=blue]Double[/COLOR] = 1.0# / (1440.0# * 60.0#)        
[COLOR=blue]Dim[/COLOR] dblWaitTil [COLOR=blue]As[/COLOR] [COLOR=blue]Date[/COLOR]        
Now.AddSeconds(OneSec)        
dblWaitTil = Now.AddSeconds(OneSec).AddSeconds(dblSecs)        
[COLOR=blue]Do[/COLOR] [COLOR=blue]Until[/COLOR] Now > dblWaitTil            
[COLOR=#2b91af]      Application[/COLOR].DoEvents() [COLOR=green]' Allow windows messages to be processed[/COLOR]        
[COLOR=blue]Loop[/COLOR]     
[COLOR=blue]End[/COLOR] [COLOR=blue]Sub
[/COLOR]

In Label1_TextChanged event

VB.NET:
[COLOR=blue]Dim[/COLOR] i [COLOR=blue]As[/COLOR] [COLOR=blue]Integer[/COLOR] = 0
i = Val(Label1.Text) + 1
'[Repeated code here]
Delay(1)
Label1.Text = i

then in form1_load event

label1.text = "1"

to make a variable global, instead of 'dim i as integer' => 'PUBLIC i as integer

A little out of the scope of you Q. sorry
 
Last edited:
Back
Top