Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Oct 3rd, 2006, 11:12 AM   #1
PhilBon
Hobbyist Programmer
 
PhilBon's Avatar
 
Join Date: Nov 2005
Posts: 172
Rep Power: 3 PhilBon is on a distinguished road
Send a message via AIM to PhilBon Send a message via MSN to PhilBon
Storing Variables with Multiple Dialogs/Forms

The Project that I am currently working on contains 6 different Dialog Boxes. It is the same idea of installing a program of after you've entered in certain info you go on to the next screen. I'm fine with that my problem is storing the variables in a location that wont change. I created a main class that will hold all the variables. The Problem is when ever I reference it as "Dim MainClass as New Main", it resets all the varibles, does anyone knoe how to store varibles between multiple dialogs/form windows? So When I set a variable in Form1 that in Form6 it will be what I had set it to in Form1. Thanks,
PhilBon is offline   Reply With Quote
Old Oct 3rd, 2006, 1:20 PM   #2
King
Professional Programmer
 
King's Avatar
 
Join Date: Jan 2006
Location: Ontario, Canada
Posts: 376
Rep Power: 0 King is an unknown quantity at this point
When you create each new form you could pass the variables to it. I am not too familiar with VB, but you probably also make a static class.
__________________
I am Addicted to Linux!
King is offline   Reply With Quote
Old Oct 3rd, 2006, 1:21 PM   #3
codetaino
Programmer
 
codetaino's Avatar
 
Join Date: Jan 2005
Location: Bayamon, Puerto Rico
Posts: 71
Rep Power: 4 codetaino is on a distinguished road
Smile

If I understand correctly you want a variable that stays the same no matter how many times you create a new instance of the main object? If this is the case then what you need is to reasearch about what is called in other languages as static members (in vb.net Shared Members) This type of members will be the same in all the instances you create of the class. A change in one instance will affect others. an example of a declaration of a shared property could be:
Public Shared Poperty myProperty() As Integer
    Get
        Return myPopertyVar 'myPropertyVar is dlecared outside this code
    End Get
    Set(ByVal Value As Integer)
        myPropertyVar = Value
    End Set
End Property

If I mistake what you are trying to do please reply and ill try to give you a more accurate answer

-codetaino
__________________
"God bless u all" :)
codetaino is offline   Reply With Quote
Old Oct 3rd, 2006, 1:53 PM   #4
Allensb
Newbie
 
Join Date: Sep 2006
Location: Fl
Posts: 5
Rep Power: 0 Allensb is on a distinguished road
Quote:
I'm fine with that my problem is storing the variables in a location that wont change.

Create a module and store you variables in the module. Then you can just reference the variables by modulename.variablename..
Allensb is offline   Reply With Quote
Old Oct 3rd, 2006, 3:30 PM   #5
MBirchmeier
Hobbyist Programmer
 
Join Date: Oct 2005
Posts: 211
Rep Power: 3 MBirchmeier is on a distinguished road
King has two valid ways of doing this, I'd be apt to lean towards the variable passing method than the static class method, however it you're only using it for these 6 variables a static class might be the way to go.

I've seen too many projects where 'static' class variables tend to become a dumping ground for global variables without actually calling them global variables.

However, the downside to passing the information back and forth, is you actually need to keep track of it, and pass it back and forth.

-MBirchmeier
MBirchmeier is offline   Reply With Quote
Old Oct 3rd, 2006, 8:38 PM   #6
lectricpharaoh
Caffeinated Neural Net
 
lectricpharaoh's Avatar
 
Join Date: Jun 2005
Location: Dry west coast of Canada
Posts: 1,033
Rep Power: 5 lectricpharaoh will become famous soon enough
One thing you could do is declare the instance as public, and then just reference it from the other classes. To avoid having it be a plain global, you can make each variable a property of the class. Taking this one further, you could make this public instance a public property of one class, and then each other class could access it. Properties in VB (indeed, all the .NET languages that support them) are like public variables, except each is actually accessed through a custom function, so you can provide validation and adjust other members (properties or otherwise) if one property changes.
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot.
- Vaarsuvius, Order of the Stick
lectricpharaoh is offline   Reply With Quote
Old Oct 11th, 2006, 7:14 AM   #7
melbolt
Hobbyist Programmer
 
melbolt's Avatar
 
Join Date: Feb 2005
Location: PA, USA
Posts: 242
Rep Power: 4 melbolt is on a distinguished road
Send a message via AIM to melbolt Send a message via Yahoo to melbolt
you could raise an event and pass the data through event args.
__________________
I have never let my schooling interfere with my education. -Mark Twain-

Xbox live gamertag: melbolt
melbolt is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple conditions in an #ifdef statement JawaKing00 C 8 Apr 26th, 2006 4:11 PM
Storing variables to a file? Oddball PHP 2 Mar 21st, 2006 2:09 PM
[Efficiency] Variables vs. Calculations kurt C 7 Dec 29th, 2005 2:39 PM
Dynamic memory - variables darkone916 C++ 4 Dec 7th, 2005 6:24 AM
multiple definition of variables in include files carlgreen C++ 3 Feb 26th, 2005 7:02 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 8:15 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC