I'm trying to create a function that will loop through a ControlCollection and apply a user specified 'mode' to it (such as enabled = false, or clearing a textbox, etc).
This is what I have so far. I'd like to be able to concatinate a the user supplied mode with CType(i, TextBox) {Eventually I'd like to make even the object type to check be dynamic}.
For example the user calls this:
setMode(grpDisplay.Controls, clear)
Would clear all of the textboxes in the group box.
I've tried
Ctype(i, TextBox). & mode
this give me Identifier Expected.
So, this brings me to my questions:
Is there any way to use a string as an object property? Or am I going to have to admit defeat and use a giant switch?
Code:
Public Function setMode(ByRef controls As Control.ControlCollection, ByVal mode As String) As Boolean
Dim i As Control
Dim command As String
For Each i In controls
If TypeOf i Is TextBox Then
End If
Next
End Function
This is what I have so far. I'd like to be able to concatinate a the user supplied mode with CType(i, TextBox) {Eventually I'd like to make even the object type to check be dynamic}.
For example the user calls this:
setMode(grpDisplay.Controls, clear)
Would clear all of the textboxes in the group box.
I've tried
Ctype(i, TextBox). & mode
this give me Identifier Expected.
So, this brings me to my questions:
Is there any way to use a string as an object property? Or am I going to have to admit defeat and use a giant switch?