Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

variable question

Status
Not open for further replies.

Octagon6

Programmer
Mar 18, 2003
18
US
Hi all... I'm new with vfp. I'ved worked with vb and java but I'm pretty lost when it comes to this language.

Anywho, my question is this. How do you assign variable to a label class or a text class?? I'ved tried using txt1 = ln1, but that doesn't work (data type mismatch.)

Another quick question, when you declare a variable (Local this_is_my_variable), how does it know if it's a string or a integer or whatever. In vb, it would be like dim strname as string. but how is it defined in vfp?

Sorry these are stupid questions, but I'm a beginner at this.
 
To assign a variable to a control, you use something like:

txt1.Value = ln1

txt1 is an object, so you need to drill down to the value to assign it.
Fox has no strict data typing like other languages. It is up to the programmer to keep track of the type. In fact, although it is bad practice, a variable can have a numeric value, and later be assigned a character value. A lot of responsibility is placed on the programmer to keep track of the data types. Usually you would use something like:

lnMyVar to specify a 'l'ocal 'n'umeric data type.
cMyVar to specify a 'c'haracter (string) data type which is not local to a procedure or 'Sub'.

You may want to peruse this website to get a handle on VFP before getting too deep into it:
Dave S.
[cheers]
 
Hi Octagon6,

1.
ThisForm.Label1.Caption = "My Label Caption"
ThisForm.Text1.Value = "my TextBox character Value"
ThisForm.Text1.Value = 0 && numeric value
ThisForm.Text1.Value = .t. && logical .t. or .f.
.. etc..

2. To create a variable in a method..

LOCAL cVal, nVar etc...
cVal = "my char value"
nVal = 0

The notation cVal or nVal is to identify for yourself the type of variable.. on the contrary.. if you specify..
cVal = 0.. the code will be true and no problems.. except when you read.. you will get misguided.

These variables are local variables and will be available for that method only.

If you declare..
PUBLIC cVar, nVar.. such declared variables are available on a global basis.

:)
ramani :)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top