|
-
Nov 10th, 1999, 10:16 PM
#1
Thread Starter
Addicted Member
Hey there. I'd need professional help =) I'm trying to create a collection with all the controls (mainly textboxes) that I will specify. After this is done, I will loop though the collection and set these controls to .visible = False. That means I need to refer to them.
I tried reading the help topic on collections, containers, containedcontrols, vbcontrols and some other topics and couldn't find any way of doing this by myself. So here I am.
Thanks for the help.
(If I cannot do this, I thought I could simply add the control names to a collection or an array, but then is there any way of using that string, ex.: "txtMyControl", and referencing to it?)
-
Nov 10th, 1999, 11:26 PM
#2
This is the code behind a command button for an example where there are three Textboxes on a form. When the command button is clicked, the forecolor of the objects in the collection change.
Code:
Private Sub Command1_Click()
Dim MyCollection As New Collection
Dim nCount As Integer
MyCollection.Add Text1
MyCollection.Add Text3
For nCount = 1 To MyCollection.Count
MyCollection.Item(nCount).ForeColor = vbRed
Next nCount
End Sub
A word of caution. You can add anything to a collection, like a vertical scrollbar that desn't have a forecolor property. Doing that will yield an error when you run through the loop.
------------------
Marty
-
Nov 10th, 1999, 11:31 PM
#3
Junior Member
Dim c As Object
For Each c In Form1
If TypeOf c Is TextBox Then
c.Visible = False
End If
Next c
I hope this is what u want.
-
Nov 10th, 1999, 11:48 PM
#4
Thread Starter
Addicted Member
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
|