Results 1 to 5 of 5

Thread: How to check type of control not included in the tool box?

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2014
    Posts
    42

    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.

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    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...
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3

    Thread Starter
    Member
    Join Date
    Jan 2014
    Posts
    42

    Re: How to check type of control not included in the tool box?

    P.S.
    Will TypeName (objTextBox) work?

  4. #4

    Thread Starter
    Member
    Join Date
    Jan 2014
    Posts
    42

    Re: How to check type of control not included in the tool box?

    Quote Originally Posted by LaVolpe View Post
    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.

  5. #5
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    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
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

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
  •  



Click Here to Expand Forum to Full Width