Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
For loop
Message
From
07/01/1999 14:22:24
 
 
To
07/01/1999 09:40:23
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Miscellaneous
Thread ID:
00173475
Message ID:
00173711
Views:
21
>I have about 20 control textbox and i want to change all this backcolor to grey color
>
>i have code :
>
> thisform.textbox1.backcolour = grb(225,225,225)
> thisform.textbox2.backcolour = grb(225,225,225)
> thisform.textbox3.backcolour = grb(225,225,225)
> thisform.textbox4.backcolour = grb(225,225,225)
> ....... so on
>
>
>instead of using so many code to make all textbox to grey color,
>can i use for loop to shorten the code?
>
>i.e.
> for n=1 to 20
> txt1=textbox+alltrim(str(n,2))
> thisform.txt1.backcolor=grb(225,225,225)
> endfor
>
>
>but is doesnt work!!
>anyone can help me on this


Easy

USe Macro Substitution:

If your txt boxes are names sequentially as.. txtBox1,txtBox2,etc

FOR counter = 1 to 20
l_comm = "ThisForm.txtBox"+ALLTRIM(STR(counter))+"backcolor=RGB(225,225,225)"
&l_comm
ENDFOR


Thats it

You can use macro sub for any vfp command as above!
Bernard
Previous
Reply
Map
View

Click here to load this message in the networking platform