11-08-2001, 10:31 AM
A bit of background first . . . In my game there are two main windows. The main frame everything goes on in, and the other displays character statistics.
How do I get a variable like Gold or a string like Weapon$ to be defined and modified on the main frame, and displayed on the status frame?
11-08-2001, 10:42 AM
Declare it as a PUBLIC variable. That way, you can modify the value in the variable from anywhere in the program.
At the top of your form code (not inside any sub or function), put the following:
Public Gold as Integer
Public Weapon$ as String
11-08-2001, 10:46 AM
I've done that. It doesn't seem to work.
PUBLIC Weapon as String
then later . . .
Weapon = "quarterstaff"
in the status form, in a timer(for constant updates):
WepLabel.caption = Weapon
and weplabel caption just stays at 0.
11-08-2001, 10:48 AM
Could you attach your code here so that I can take a look at it?
Try moving the Public variables into a module rather than a form.
11-08-2001, 11:59 AM
This isn't my actual game, but it acts the same. The game is much to big to post.
11-08-2001, 12:01 PM
WOW!!! It works now! Thanks!!!!!!
11-08-2001, 12:46 PM
I just realized--even if a variable is set as PUBLIC on a form, in order to refer to it from another form, you need to put formname.variablename.
But Mill's idea to put it into a module works too.