variable initialization

variable initialization

Post by Florin Cherbi » Tue, 07 Sep 1999 04:00:00



In FoxPro 2.6 for Windows, if I initialize a variable in the setup section
of a screen, using, for example:
nvar=10,
the screen knows it anywhere inside it: validation codes, cleanup code, etc.
Now I tried something similar in Visual Fox 6.0. In the Init event (and then
I tried in the Load event) of a form, I put the same famous nvar=10. I put
then a command button in that form, and in the Click event of that cmdbtn, I
put a simple instruction: wait wind str(nvar) nowa.
I tried to run the form, but when I clicked on the command button, an error
message was all that I received, saying that the nvar is unknown.
Please tell me, where should be this variables declared to be known along
the form ? Do I have to declare them as public or local? Is not enough the
old way of declaring the variables?

Thanks,
Florin Cherbis

 
 
 

variable initialization

Post by Fred » Tue, 07 Sep 1999 04:00:00


Florin,
You have to create a new property for the form, call nvar and reference it with
thisform.nvar
or make nvar public

fred

Florin Cherbis a crit:

Quote:> In FoxPro 2.6 for Windows, if I initialize a variable in the setup section
> of a screen, using, for example:
> nvar=10,
> the screen knows it anywhere inside it: validation codes, cleanup code, etc.
> Now I tried something similar in Visual Fox 6.0. In the Init event (and then
> I tried in the Load event) of a form, I put the same famous nvar=10. I put
> then a command button in that form, and in the Click event of that cmdbtn, I
> put a simple instruction: wait wind str(nvar) nowa.
> I tried to run the form, but when I clicked on the command button, an error
> message was all that I received, saying that the nvar is unknown.
> Please tell me, where should be this variables declared to be known along
> the form ? Do I have to declare them as public or local? Is not enough the
> old way of declaring the variables?

> Thanks,
> Florin Cherbis


 
 
 

variable initialization

Post by Tim Witor » Thu, 09 Sep 1999 04:00:00


To elaborate on Fred's reply:

Either create a form property (in the form designer with the form
itself selected, Form|New Property... from the designer menu.

Or, in the form's init or load method declare the variable as
public (global... sort of):

PUBLIC nVar

nVar = 10

-- TRW


> Florin,
> You have to create a new property for the form, call nvar and reference it with
> thisform.nvar
> or make nvar public

> fred

> Florin Cherbis a crit:

> > In FoxPro 2.6 for Windows, if I initialize a variable in the setup section
> > of a screen, using, for example:
> > nvar=10,
> > the screen knows it anywhere inside it: validation codes, cleanup code, etc.
> > Now I tried something similar in Visual Fox 6.0. In the Init event (and then
> > I tried in the Load event) of a form, I put the same famous nvar=10. I put
> > then a command button in that form, and in the Click event of that cmdbtn, I
> > put a simple instruction: wait wind str(nvar) nowa.
> > I tried to run the form, but when I clicked on the command button, an error
> > message was all that I received, saying that the nvar is unknown.
> > Please tell me, where should be this variables declared to be known along
> > the form ? Do I have to declare them as public or local? Is not enough the
> > old way of declaring the variables?

> > Thanks,
> > Florin Cherbis

--

--------------------------------------
Remove the "drop this" strings from my
e-mail address to reply.
--------------------------------------

 
 
 

variable initialization

Post by Fred » Fri, 10 Sep 1999 04:00:00


Hi Tim,

As I've always said to my mother, I'll never be a teacher!
But i'm sure you're one or you should   ;-)

Fred

Tim Witort a crit:

Quote:> To elaborate on Fred's reply:

> Either create a form property (in the form designer with the form
> itself selected, Form|New Property... from the designer menu.

> Or, in the form's init or load method declare the variable as
> public (global... sort of):

> PUBLIC nVar

> nVar = 10

> -- TRW