Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: Visual Basic
Expertise: Beginner
Oct 1, 1996



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Using Global Variables

I have visual basic 2.0 Hopefully not for long. If I make a button that does a funtion like this. n = n + 1 print n it gives me a 1. I then click the same button and it still gives me a 1 every time. When I put n = n + 1 two or three times in the same buttons it does the adding. Is this something to do visual basic 2.0 or do I have to declare it a global varable or something?

You do need a global variable. Define it in the declarations section of the form. Put the object list to (general) and the other list should say declarations. Dim N as integer in that section. Then, whenever or wherever you use the variable N, it will add or subtract from the same variable.

DevX Pro
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date