ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Control array (https://www.excelbanter.com/excel-programming/365931-control-array.html)

Freddie Mac

Control array
 
I have several textboxes and checkboxes. I now insert them into an array but
there is something called control array? How do you use it? My help function
does not work!

RB Smissaert

Control array
 
there is something called control array

There is in VB, but not in VBA.
If you say you have them in an array now then I am not sure you can
improve on that.

RBS

"Freddie Mac" wrote in message
...
I have several textboxes and checkboxes. I now insert them into an array
but
there is something called control array? How do you use it? My help
function
does not work!



Peter T

Control array
 
A Control Array is only available in VB6 (not VBA).

You could set up an array of With Events control class's which would lead to
similar overall functionality albeit in a different way.

Regards,
Peter T

"Freddie Mac" wrote in message
...
I have several textboxes and checkboxes. I now insert them into an array

but
there is something called control array? How do you use it? My help

function
does not work!




Scoops

Control array
 

Freddie Mac wrote:
I have several textboxes and checkboxes. I now insert them into an array but
there is something called control array? How do you use it? My help function
does not work!


Freddie are you using Excel or is this homework?


Freddie Mac

Control array
 
hmm dont get you...but I am using Excel. I have a userform in which a have
two rows of textboxes and one row of checkboxes. now i have inserted them in
an array ang it works fine. but if a user after me wants to add boxes the
array will be full and so the user must change that too. see what i mean? It
would be nicer if automatically all textboxes in a certain frame etc. would
belong to the same textbox array.

"Scoops" skrev:


Freddie Mac wrote:
I have several textboxes and checkboxes. I now insert them into an array but
there is something called control array? How do you use it? My help function
does not work!


Freddie are you using Excel or is this homework?



FourBlades

Control array
 
You've obviously read about control arrays somewhere. The problem is that
they do not exist in VBA. They exist in VB6 but not in VBA.

I wasn't clear on your exact reason for using the array. There is always a
work-around in VBA it just takes a little more work.

For example, if I want to work my way through a group of controls then I
name all of the related controls that I want to loop through like this
"Control1, Control2, Control3..." Then I set up a FOR-NEXT LOOP.

For each Control in (whatever object you are working with) if Control.name
like "Control*" then
In here I then use Strings.left or Strings.right to sequence my way
through
each of the ending digits. Or I use some other variation on this
theme.
End if

It works just fine.

NickHK

Control array
 
As others have pointed out, Excel does not have control arrays in the sense
that VB does.
So how are you creating your array of textboxes?

NickHK

"Freddie Mac" wrote in message
...
hmm dont get you...but I am using Excel. I have a userform in which a have
two rows of textboxes and one row of checkboxes. now i have inserted them

in
an array ang it works fine. but if a user after me wants to add boxes the
array will be full and so the user must change that too. see what i mean?

It
would be nicer if automatically all textboxes in a certain frame etc.

would
belong to the same textbox array.

"Scoops" skrev:


Freddie Mac wrote:
I have several textboxes and checkboxes. I now insert them into an

array but
there is something called control array? How do you use it? My help

function
does not work!


Freddie are you using Excel or is this homework?





Martin Miller

Control array
 


"Freddie Mac" wrote:

I have several textboxes and checkboxes. I now insert them into an array but
there is something called control array? How do you use it? My help function
does not work!


This will work.

testNumber = Me.Controls("txtStart" & CStr(1))

Me.Controls("txtStart" & CStr(2)) = testNumber

So it you have textboxes named txtStart1, txtStart2, txtStart3 etc. You
obviously would use variable instead of the 1 and 2 I used.


All times are GMT +1. The time now is 08:19 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com