|
-
Aug 17th, 2001, 12:49 AM
#1
Thread Starter
New Member
How to use control arrays
hai friends,
Throw light on how to use control arrays. i understood that if controls performing the same task can be grouped under a array but my problem is
+ buttons has to increment by 1 for each event.
there are 3 buttons .
but in the case of 2 button the condition to be checked is
the number should not exceeed 23 and in the remaining cases
59. How to include such conditions in an array.
Bye
-
Aug 17th, 2001, 12:54 AM
#2
Hyperactive Member
Dim objButton as CommandButton
For each objButton in Me.Controls
If objButton.Caption = "Do this" then
'Do this
Endif
Next
OR
Dim objControl as Control
For each objcontrol in Me.Controls
If Typeof objcontrol is CommandButton then
If objButton.Caption = "Do this" then
'Do this
Endif
Endif
Next
William T
Software Architect / Chief Software Developer
Softwaremaker.Net Pte Ltd
http://www.Softwaremaker.net
*** Things are always the darkest before they go pitch black ***
-
Aug 17th, 2001, 02:56 AM
#3
Retired VBF Adm1nistrator
SoftwareMaker, you are using control enumeration, not basic control arrays.
sudir_ks, can you be more precise as to what you want to do ?
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
Aug 17th, 2001, 03:38 AM
#4
Hyperactive Member
Ooppss..
Sorry...Control Arrays are created by using controls on a form with the same name but with different indexes.
so you have 5 CommandButtons on the same form with the same name such as cmdNavigate. They will all have different indices. Try creating 2 controls on a form with the same name and VBIDE will ask you if you want to have a control array. Say Yes...
So you will have 5 command buttons with the reference
cmdNavigate(0)
cmdNavigate(1)
cmdNavigate(2)
cmdNavigate(3)
From there, you can refer to any one of these controls by a method like this
For i = 0 to cmdNavigate.Count
cmdNavigate(i).Caption = "Button " & i
Next
Thanks plenderj for highlighting my mistake
William T
Software Architect / Chief Software Developer
Softwaremaker.Net Pte Ltd
http://www.Softwaremaker.net
*** Things are always the darkest before they go pitch black ***
-
Aug 17th, 2001, 07:29 AM
#5
Retired VBF Adm1nistrator
I still dont know what you're trying to acheive sudir_ks.
Take a look at the attachment. It might explain it for you ?!
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|