Text Box Controls in an Array - setting properties problem

dom_donald

Registered User.
Local time
Today, 14:06
Joined
Apr 30, 2004
Messages
22
hi.. i'm having a problem with some VB code.. i'm trying to add some controls to an array of controls so that I can later manipulate them more easily.

But when i've initialised the arrays with the controls, i have problems setting some of the properties of those controls. When i try to view the arrays in the watch window of the debugger, I see that only some of them are actually objects. Other text boxes only seem appear as Variant/String rather than Variant/Object. I then get the "Object Required" error at runtime.

Firstly i don't know if i'm using the right syntax to create the arrays and secondly i don't know if i should be using variant arrays in the first place! Help! ;)

Dim P_T1_Controls As Variant
Dim P_T2_Controls As Variant
Dim P_T3_Controls As Variant
Dim P_T4_Controls As Variant
Dim P_E_Controls As Variant
Dim P_Controls As Variant ' 2D array

'initialise the arrays
P_T1_Controls = Array(T1, T1_Curr, T1_Ex, T1_Hours, T1H_Rate, T1_Words, T1W_Rate)
P_T2_Controls = Array(T2, Me.T2_Curr, T2_Ex, T2_Hours, T2H_Rate, T2_Words, T2W_Rate)
P_T3_Controls = Array(T3, Me.T3_Curr, T3_Ex, T3_Hours, T3H_Rate, T3_Words, T3W_Rate)
P_T4_Controls = Array(T4, Me.T4_Curr, T4_Ex, T4_Hours, T4H_Rate, T4_Words, T4W_Rate)
P_E_Controls = Array(E, E_Curr, E_Ex, E_Hours, EH_Rate, E_Words, EW_Rate)

'put these into the 2D array
P_Controls = Array _
(P_T1_Controls, P_T2_Controls, P_T3_Controls, P_T4_Controls, P_E_Controls)

'and later access the controls in a loop and set properties
P_Controls(Id)(Sub_Id).Visible = True
P_Controls(Id)(Sub_Id).Enabled = True
P_Controls(Id)(Sub_Id).Locked = False
P_Controls(Id)(Sub_Id).SpecialEffect = 2


======================

this works for Id = 0, Sub_Id = 0 but not for any of the others - yet they are all text boxes...
 
ok, now i think i am accessing my arrays with the wrong syntax :( Hmm I'll faff around for a bit more! :D
 
OK, I've searched the forums again and found the answer I was looking for i.e. i've done it all wrong :)

:D
 
Help!!

Sorry to bring this up again but how did you get around this problem I am trying to do the same thing


Thanks :)
 

Users who are viewing this thread

Back
Top Bottom