Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


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

Using Global Variables

Question:
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?

Answer:
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.

 

 

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