Register | Login
Views: 19364387
Main | Memberlist | Active users | ACS | Commons | Calendar | Online users
Ranks | FAQ | Color Chart | Photo album | IRC Chat
11-02-05 12:59 PM
0 user currently in Programming. | 3 guests
Acmlm's Board - I2 Archive - Programming - VB Variables and Modules question
  
User name:
Password:
Reply:
 

UserPost
RoboticParanoia
Posts: 85/184
I figured out how to work it out, so everything is a-okay.

The only thing now, is the subroutines, and the file organization...which I'm terrible at. =P

But, thank you everyone, for your help, I appreciate it.
HyperLamer
Posts: 1253/8210
DON'T DO IT! If you refer to something in a form that's not loaded, it'll automatically load, and you'll go aaaaarrrggghhh trying to figure out WTF happened. All public variables and functions should be put in modules, unless you have a form that is always loaded.
RoboticParanoia
Posts: 83/184
Well, thank you everyone.

There's generally going to be only one form...I just kinda wanted to make my software a bit more open, so people can add more features (or in my case, a game), and I thought using modules might work.

I guess I'll toy around with it for a while.
dormento
Posts: 35/99
Like Lord Duran said, there's really no incentive whatsoever to declare public variables on a form. If you want your variables to be seen outside of the form, declare them in a module.
Tip: You can avoid some problems putting Option Explicit on the top of your forms and code modules. It tells Visual Basic to assume that any reference to an undeclared variable is an error. If there's no Option Explicit, every time you reference a variable that isn't declared, VB silently creates a variable of type Variant (versatile but slow and bloated ).
What i generally do is to create a module where i declare all my constants and public variables, types, enums etc.
If you're really really desperate about acessing a form's public variables from inside a module, you can do {formname}.{variablename}=... , but as LD said, the variable goes poof when the object is unloaded.
Hope that helps
Deleted User
Posts: 1/12
The form has to be loaded to memory. That is, no unload form, or the variable goes to hell. But it's a generally bad idea to declare global variables in forms. You'd be much better off just loading the module from the start manually and declaring the variable there.
interdpth
Posts: 90/527
Prolly if you declare them in a type like this

Private Type tType
one as integer
two as string
end type


private Type() as tType


For calling the variables use
Private. Variable
Darth Coby
Posts: 783/1371
Not sure about variables, but I know you can use parts of a form in a module.
Just use
With formname
bla bla code bla
.txtTextfield = blabla

That might work with variables too.
RoboticParanoia
Posts: 80/184
Here is my question:

Let's say you created some public variables on a form. Can these variables be referred to (like let's say through If...Then statements or whatever) on a public module?

If not, then how can I get it to work so that the variables can be referred on the module?
Acmlm's Board - I2 Archive - Programming - VB Variables and Modules question


ABII


AcmlmBoard vl.ol (11-01-05)
© 2000-2005 Acmlm, Emuz, et al



Page rendered in 0.004 seconds.