+ Reply to Thread
Results 1 to 4 of 4

Text Boxes (Values) if blank equal to 0

  1. #1
    Registered User
    Join Date
    06-29-2012
    Location
    Denver, Colorado
    MS-Off Ver
    Excel 2007
    Posts
    4

    Text Boxes (Values) if blank equal to 0

    Hello,

    This is my first post, so I apologize if was posted in the wrong forum. Thank you in advance for reading and any assistance you provide to rectify the issue.

    I have created a form with multiple (7) Text Boxes a user will enter data into. There is one Command Button that if clicked will perform multiple (3) calculations simultaneously and display the results of the calculation in a respective Label for that data. The problem is, some of the Text Boxes could be equal to "0". I would prefer a user to have the option of either entering "0" into the box or simply leave it blank. If left blank, clicking the Command Button would calculate as it should, but uses "0" for the blank fields. At the moment, if the fields are left blank, I receive an error.

    Here is what I have so far, which works if I enter "0" into the text fields I would like to leave blank:
    Please Login or Register  to view this content.
    Last edited by Leith Ross; 06-29-2012 at 03:10 PM. Reason: Added Code Tags

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Text Boxes (Values) if blank equal to 0

    Hello Gomquai,

    Welcome to the Forum!

    Replace the CDbl statements with Val. The Val statement will return a double value but will not error if it encounters a non numeric value in the text string.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    06-29-2012
    Location
    Denver, Colorado
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Text Boxes (Values) if blank equal to 0

    You are a gentleman and a scholar, Sir! That works like a charm!

    Excellent first experience! My hats off to you!

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Text Boxes (Values) if blank equal to 0

    Hello Gomquai ,

    You're welcome. Thanks for joining our community.

+ 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