+ Reply to Thread
Results 1 to 8 of 8

how to call a text box?

  1. #1
    Registered User
    Join Date
    05-03-2010
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    59

    how to call a text box?

    I have a userform and I want to call it in an if statement... i want to do something like if IsEmpty(Textbox) then
    [code]


    How do I call the textbox?

  2. #2
    Registered User
    Join Date
    06-01-2010
    Location
    Canada
    MS-Off Ver
    Excel 2003
    Posts
    47

    Re: how to call a text box?

    if your form is called 'userForm1' then the code is
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    05-03-2010
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    59

    Re: how to call a text box?

    i dont mean to show the textbox, i just mean to call the textbox like a variable.

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: how to call a text box?

    Hi,

    Please Login or Register  to view this content.
    HTH
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  5. #5
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: how to call a text box?

    Hi papermoon

    Perhaps you're looking for something like this

    Please Login or Register  to view this content.
    John
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  6. #6
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,998

    Re: how to call a text box?

    FYI, in order to be able to refer to the textbox's value, the userform must be loaded. If you simply refer to say Userform1.Textbox1.Value in your code, then the form will be implicitly loaded and you will get the default value of the text box - usually "". This is one good reason not to use the default instancing.
    Everyone who confuses correlation and causation ends up dead.

  7. #7
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: how to call a text box?

    Hi romperstomper

    This
    If you simply refer to say Userform1.Textbox1.Value in your code, then the form will be implicitly loaded
    once or twice and I didn't know why. Thanks for the feedback.

    John

  8. #8
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,998

    Re: how to call a text box?

    That's why it's better to use something like:
    Please Login or Register  to view this content.
    and make sure that your form gets hidden not unloaded. Then if it has been unloaded somehow, you'll get an error when you try and access its controls/properties rather than a new instance created (which can make debugging really hard!)

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1