Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a frame containing a dozen or so check boxes.
They've been added at various times and I've probably deleted some and added others. In some code I count the number of controls, and in a loop with say 'x' as a loop counter, I test the tag property of the control(x). I've been having some problem with this and I now realise that what I believed to be say the 3rd checkbox, ( because I thought it was the third one I'd added), is actually recognised by VBA as say the 5th checkbox, (identified by the x counter). i.e. Controls(x) It seems clear that in all my additions and deletions, the system number of the control is different to what I think it is. My question is, is there any way of re-setting the system numbers of these controls so that they line up with the order in which they appear in the frame? An associated question. Is there any way of observing directly what the control number of a particular control is? I can obviously work it out indirectly by writing a bit of code which tells me say the Tag or Caption associated with a particular control, but it's not immediately apparent if the system number is a property of the control which can be viewed - and changed (in a similar way to the way in which the Tab property number can be changed). Rgds and usual TIA __ Richard Buttrey Grappenhall, Cheshire, UK __________________________ |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
AFAIK the index of the control is determined by the order in which the
controls are added, and cannot be changed. -- HTH RP (remove nothere from the email address if mailing direct) "Richard Buttrey" wrote in message ... I have a frame containing a dozen or so check boxes. They've been added at various times and I've probably deleted some and added others. In some code I count the number of controls, and in a loop with say 'x' as a loop counter, I test the tag property of the control(x). I've been having some problem with this and I now realise that what I believed to be say the 3rd checkbox, ( because I thought it was the third one I'd added), is actually recognised by VBA as say the 5th checkbox, (identified by the x counter). i.e. Controls(x) It seems clear that in all my additions and deletions, the system number of the control is different to what I think it is. My question is, is there any way of re-setting the system numbers of these controls so that they line up with the order in which they appear in the frame? An associated question. Is there any way of observing directly what the control number of a particular control is? I can obviously work it out indirectly by writing a bit of code which tells me say the Tag or Caption associated with a particular control, but it's not immediately apparent if the system number is a property of the control which can be viewed - and changed (in a similar way to the way in which the Tab property number can be changed). Rgds and usual TIA __ Richard Buttrey Grappenhall, Cheshire, UK __________________________ |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Richard
In general, it is better practice to rename the controls yourself and then adress the control by its name iso by index. another way is to create your controls at run time and record their name in an array. Regards Jean-Yves "Richard Buttrey" wrote in message ... I have a frame containing a dozen or so check boxes. They've been added at various times and I've probably deleted some and added others. In some code I count the number of controls, and in a loop with say 'x' as a loop counter, I test the tag property of the control(x). I've been having some problem with this and I now realise that what I believed to be say the 3rd checkbox, ( because I thought it was the third one I'd added), is actually recognised by VBA as say the 5th checkbox, (identified by the x counter). i.e. Controls(x) It seems clear that in all my additions and deletions, the system number of the control is different to what I think it is. My question is, is there any way of re-setting the system numbers of these controls so that they line up with the order in which they appear in the frame? An associated question. Is there any way of observing directly what the control number of a particular control is? I can obviously work it out indirectly by writing a bit of code which tells me say the Tag or Caption associated with a particular control, but it's not immediately apparent if the system number is a property of the control which can be viewed - and changed (in a similar way to the way in which the Tab property number can be changed). Rgds and usual TIA __ Richard Buttrey Grappenhall, Cheshire, UK __________________________ |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Wed, 17 Aug 2005 14:44:22 +0200, "Jean-Yves"
wrote: Hi Richard In general, it is better practice to rename the controls yourself and then adress the control by its name iso by index. another way is to create your controls at run time and record their name in an array. Regards Jean-Yves Thanks Jean, (and Bob earlier), The only reason I was using the index number was that I did domething different with the first eight listed checkboxes than with the rest. I was using a simple Select statement assuming I could rely on the control index number as the Select Case i.e. Case<8. I now see I can't and will follow the advice you suggest. Incidentally, is it possible to see a control index number directly, or can this only be done by writing a bit of code to identify the control name of each control index number? Incidentally2. Are control index numbers always base zero? Rgds __ Richard Buttrey Grappenhall, Cheshire, UK __________________________ |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How do I get a index% of two numbers when they are negative or pos | Excel Worksheet Functions | |||
Multipage Control Pages - Changing Index Value in Code | Excel Programming | |||
Multipage Control Pages - Changing Index Value in Code | Excel Programming | |||
Return Index of Control Object Clicked! | Excel Programming | |||
Accesing a combobox control via it index propertie in VBA, Is itPossible? | Excel Programming |