format text as number - new programmer

  • I chose to have my users enter values in text-boxs. How do I automatically reformat the text to be numbers so that I can manipulate the data.


    For instance the user enters a number into the "number of widgets" textbox. I then want to take the number and multiple by unit price, but I get #N/A.


    Thanks for your help

  • Quote

    Originally posted by baprince
    I chose to have my users enter values in text-boxs. How do I automatically reformat the text to be numbers so that I can manipulate the data.


    For instance the user enters a number into the "number of widgets" textbox. I then want to take the number and multiple by unit price, but I get #N/A.


    Thanks for your help


    Try something like this:


    CDbl(InputBox("Enter the value"))


    This will convert the value entered in the inputbox to a double data type. NOTE - you should put in some error handling for this in case the user enters something that can't be converted to a number. Like "Barrie", for example.

    Barrie Davidson
    My Excel Web Page
    "You're only given a little spark of madness. You mustn't lose it." - Robin Williams

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!