Varibles - reuseable?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello.

If I have declared a varible in an event handler, can I ues it again in the
same form but in another event handler? Thanks.
 
Xero,

The answer is no, however maybe you can explain why you want to o that?

Cor
 
Hello.

If I have declared a varible in an event handler, can I ues it again in the
same form but in another event handler? Thanks.

If declared locally to the event handler, you can use the same variable
name in another event handler

--
Chris

dunawayc[AT]sbcglobal_lunchmeat_[DOT]net

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.
 
Xero,
An Event Handler is simply a subroutine.

You can use the same name for variables in any number of subroutines,
however each subroutine would have its own variable.

What specifically are you asking?

Do you want one event to set a variable & a second event to use that same
variable? You need to use a Class/Form level variable in that case.

See "Scope" in the Visual Basic Language Reference:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbls7/html/vblrfVBSpec4_6.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcn7/html/vbconScope.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcn7/html/vbconScopeLevels.asp

Hope this helps
Jay
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top