Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Correct ThisForm.Objectname.Property syntax ?
Message
 
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00142404
Message ID:
00142451
Views:
19
Brian,

The form has a Controls[] collection that you can use to iterate through the controls. You could also put all the controls into a Container class and just set the Container.Enabled.

> ThisForm.txtAuxname[x].Enabled = .T.

>But I keep getting an error "TXTAUXNAME" not found. Why is it not adding the value of [x] on the end and using the intended object name?

Your syntax is treating txtAuxname as an array property.

You could avoid macros with:
for i = 1 to 17
   lcControl = "txtAuxname" + alltrim(str(i))
   loControl = eval( lcControl )
   with loControl
      .Enabled = .f.
   endwith
>I've had to resort to building the command and using macro substitution to run it to get the intended results:
>
>FOR x = 1 TO 17
> cCommand="ThisForm.txtAuxname"+ALLTRIM(STR(x))+".Enabled"+"=.T."
> &cCommand
>ENDFOR
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Previous
Reply
Map
View

Click here to load this message in the networking platform