-
Apr 22nd, 2015, 02:17 PM
#1
Thread Starter
Member
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.
-
Apr 22nd, 2015, 02:23 PM
#2
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...
-
Apr 22nd, 2015, 02:27 PM
#3
Thread Starter
Member
Re: How to check type of control not included in the tool box?
P.S.
Will TypeName (objTextBox) work?
-
Apr 25th, 2015, 02:51 AM
#4
Thread Starter
Member
Re: How to check type of control not included in the tool box?
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.
-
Apr 25th, 2015, 10:03 AM
#5
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
Tags for this Thread
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
|