|
-
Jul 18th, 2004, 07:06 PM
#1
Thread Starter
PowerPoster
TabIndex, Tag and stuff
I've been writing a few test routines where I need to iterate through labels that emulate LED's. I've got things working OK, first of all using this:
VB Code:
For Each ctrl In Me.GroupBox2.Controls
If TypeOf ctrl Is Label Then
' some code
Indx += CByte(1)
End If
Next
That works fine, though I've had to reverse the order of data fed to it, bizarrely the for each...next loop works backwards through the controls However, it doesn't feel comfortable just assuming that the app will always iterate through the controls in the correct order, so I incorporated the TabIndex:
VB Code:
For Each ctrl In Me.GroupBox2.Controls
If TypeOf ctrl Is Label AndAlso ctrl.TabIndex = Indx Then
' some code
Indx += CByte(1)
End If
Next
Which also works fine. Now the question is, are there any pitfalls from using the TabIndex like this, such as if I add any controls will it lead to any difficulties? Because the real app needs to be scaled up to include hundreds of labels, I'd rather get the code right now than find out later 
Also, I tried using the Tag property, where I assigned a numeric value to each label.tag. However, Intellisense moans about Option Strict not allowing me to use the = operator, and I just can't find a way of using Tag. Am I barking up the wrong tree by trying to use Tag in this way?
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
|