How to check type of control not included in the tool box?
I have put the subs and functions that I use the most in a standard module.
Including this:
Sub ReadArrayIntoTextBox(anArray() As String, objTextBox As Control)
If (Not TypeOf objTextBox Is TextBox) And (Not TypeOf objTextBox Is RichTextBox) Then Exit Sub
................
End Sub
The program works fine, because this Sub is never called.
But the project will not compile because there is no RichTextBox control in the tool box.
Is there a way to assign type of control to a variable, something like:
sType = TypeOf (objTextBox)
Appreciate help.
Re: How to check type of control not included in the tool box?
If you know the control's typename, you can use that
Code:
If TypeName(objTextBox) = "RichTextBox" Then...
Re: How to check type of control not included in the tool box?
P.S.
Will TypeName (objTextBox) work?
Re: How to check type of control not included in the tool box?
Quote:
Originally Posted by
LaVolpe
If you know the control's typename, you can use that
Code:
If TypeName(objTextBox) = "RichTextBox" Then...
Yes, TypeName(objTextBox) works because, by definition, objTextBox is always known.
On the other other hand, "TypeOf ... Is RichTextBox" will not compile unless RichTextBox is included in the project.
Thanks.
Re: How to check type of control not included in the tool box?
If for any reason objTextbox can be "Nothing", that could be a check also: If Not (objTextBox Is Nothing) Then determine what type of control