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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Controls in an array

Status
Not open for further replies.

trystanhuwwilliams

Programmer
Aug 23, 2002
39
0
0
GB
Thank you everyone for the tips on the leap year issue & although the 2000 % 4 isn't ideal - i only need to test for leap year's from 2000 to 2010.

On another point, I'd like to find out if it's possibe to store controls on a form within an array & and then use the array indices to reference the controls.

Is something similar to this possible? :-
Code:
OPTION BASE 1
SET VAR_CONTROLS("C1","C2,"C3")
'C1,C2,C3 are all controls(TEXT BOXES) on a form
FOR X=1 TO 3
[VAR_CONTROLS(X)].VALUE = 1
NEXT X

Thanks again,
Trystan





 
Trystan,

I have done something like this in the past:

1. Name objects in sequencial order. (Example: txtVal1, txtVal2, txtVal3, etc.)

2. Then I would right a sub routine that does the following:
Code:
Sub MySub()

Dim obj as Object
Dim frm as Form

Dim Intvl as Long

Set frm = Me.Form

For Intvl = 1 to 3
   Set obj = frm("txtVal" & Intvl)
   obj.Value = "Test Example " & Intvl
Next Intvl

End Sub
You could also get more specific and Dim the object as the specific object type. In this example, I could use Dim obj as TextBox instead of Dim obj as Object.

God Bless,
Mike

Yes, I believe in Jesus. ;-)
"Neither is there salvation in any other: for there is none other name under heaven given among men, whereby we must be saved." (Acts 4:12, KJV)
 
Oh and to actually answer your question... LOL

I think what you are wondering would work, but you would have to specifically set each object in the array.

I prefer my method... It takes less work, and it is easier to adapt to programming changes. God Bless,
Mike

Yes, I believe in Jesus. ;-)
"Neither is there salvation in any other: for there is none other name under heaven given among men, whereby we must be saved." (Acts 4:12, KJV)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top