Using strings with multiple forms

Gamer X
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?
-Gamer X

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

Gamer X
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.

-Gamer X

11-08-2001, 10:48 AM
Could you attach your code here so that I can take a look at it?

11-08-2001, 11:21 AM
Try moving the Public variables into a module rather than a form.

Gamer X
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.

Gamer X
11-08-2001, 12:01 PM
WOW!!! It works now! Thanks!!!!!!
-Gamer X

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.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum