+ Reply to Thread
Results 1 to 3 of 3

Convert text in a textbox to a number (VBA)

  1. #1
    Forum Contributor
    Join Date
    09-25-2012
    Location
    Philadelphia, PA
    MS-Off Ver
    Excel 2010
    Posts
    154

    Convert text in a textbox to a number (VBA)

    I have a textbox where after the user inputs a number (100000) the afterupdate event formats this as text

    Please Login or Register  to view this content.
    When I want to work with this value in the code (i.e. to perform other math) I need to convert this back to a number. Is there a simple way to do this? I don't want to set up the textbox to have a controlsource for other reasons
    pls click the star if you liked my answer!

  2. #2
    Forum Expert
    Join Date
    02-22-2013
    Location
    London, UK
    MS-Off Ver
    Office 365
    Posts
    1,218

    Re: Convert text in a textbox to a number (VBA)

    For instance, you can try -- before the variable to convert to number or use CDbl() to convert to double:
    Please Login or Register  to view this content.
    Cheers,
    berlan
    Last edited by berlan; 03-03-2015 at 05:15 PM.

  3. #3
    Forum Contributor
    Join Date
    09-25-2012
    Location
    Philadelphia, PA
    MS-Off Ver
    Excel 2010
    Posts
    154

    Re: Convert text in a textbox to a number (VBA)

    Hey Berlan,

    What if my textbox is a percentage, such as 11.5%. I think the Cdbl function results in a mismatch error.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 5
    Last Post: 11-30-2014, 07:56 AM
  2. [SOLVED] Convert Userform textbox to decimal number
    By Leandrial in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-27-2012, 02:08 PM
  3. Replies: 1
    Last Post: 10-28-2012, 05:42 AM
  4. Convert text in textbox as i type
    By pblnrao in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-22-2011, 03:37 AM
  5. [SOLVED] convert text-format number to number in excel 2000%3f
    By Larry in forum Excel General
    Replies: 1
    Last Post: 07-29-2005, 04:05 PM

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