Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old June 14th, 2006, 11:41 AM
marchigiano marchigiano is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2006
Posts: 2 marchigiano User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 25 m 26 sec
Reputation Power: 0
Help with global level variables..

In my Computer Science class, we are doing independant projects. For mine, I'm working on a text based Haunted House game. I want to be able to have users find a key in one form and be able to use it in another form. We never worked with global level variables in class so I'm not really sure how to do this. Here's sort of what I want:
When user's first try to enter this room, they can't because it's locked. Later on in the game, I want them to find a key and go back to the room and use it.
Any help would be greatly appreciated.. thank you in advance.

Reply With Quote
  #2  
Old June 14th, 2006, 02:32 PM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
Click here for more information.
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,871 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 16 h 47 m 27 sec
Reputation Power: 500
Modules store global variables.

Reply With Quote
  #3  
Old June 14th, 2006, 08:56 PM
marchigiano marchigiano is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2006
Posts: 2 marchigiano User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 25 m 26 sec
Reputation Power: 0
Quote:
Originally Posted by Memnoch
Modules store global variables.


I'm not even sure what a module is... Help?

Reply With Quote
  #4  
Old June 15th, 2006, 06:11 AM
sync_or_swim's Avatar
sync_or_swim sync_or_swim is offline
Moderator
Click here for more information.
 
Join Date: Mar 2006
Location: South Wales
Posts: 1,932 sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 6 Days 22 h 34 m 58 sec
Reputation Power: 1243
A module is basically a bit of code which is accessible by all of the forms in your project. To demonstrate how they work just add a module to your project. Go to Project -> Add Module, in the resulting "Add Module" window make sure the "New" tab is selected and the "module" icon is selected then click "Open".

You will now have a module added to your code called Module1. To demonstrate how to use it try declaring a variable in this module:
Code:
Public var As String

This variable called "var" is now accessible to all forms, to make sure of this, open up Form1 and click on the icon on the left of the three at the top of the project explorer window, to display the code for the form.

On a blank line in this code type the letters va and hold down Ctrl and press the Space Bar, you will now see a list of commands that you may type: with the command "Val" being selected, if you press the down arrow twice you will see that your variable "var" is highlighted - to select this press "Tab".

Because your variable appears on this list of commands it means that the current form can use it. To test it further, add another form to the project. Project -> Add Form -> Open, toggle to the code again and again type va and press Ctrl + Spacebar. Can you see your variable in the list?

Now you can view or alter the value of your variable called "var" on any form!!!

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > Help with global level variables..


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT