+ Reply to Thread
Results 1 to 4 of 4

Code to convert text input to a number

  1. #1
    Registered User
    Join Date
    06-29-2006
    Posts
    28

    Code to convert text input to a number

    Hi all,

    What is the code to convert text taken from a input text box (on a form) into a number that can be used for manipulation?

    Thanks

  2. #2
    Norman Jones
    Guest

    Re: Code to convert text input to a number

    Hi FCC,

    Try:

    Dim myValue As Double

    myValue = CDbl(TextBox1.Value)


    ---
    Regards,
    Norman



    "FCC" <[email protected]> wrote in message
    news:[email protected]...
    >
    > Hi all,
    >
    > What is the code to convert text taken from a input text box (on a
    > form) into a number that can be used for manipulation?
    >
    > Thanks
    >
    >
    > --
    > FCC
    > ------------------------------------------------------------------------
    > FCC's Profile:
    > http://www.excelforum.com/member.php...o&userid=35888
    > View this thread: http://www.excelforum.com/showthread...hreadid=568900
    >




  3. #3
    NickHK
    Guest

    Re: Code to convert text input to a number

    If you use the Application.InputBox instead of VBA.InputBox, you can specify
    a Type:=1 argument, to limit the user to numbers. e.g.
    Debug.Print VarType(Application.InputBox("Some prompt", , , , , , , 1))
    5
    shows that a double was returned.
    You still need to check for the Cancel, which =False.

    NickHK

    "FCC" <[email protected]> wrote in message
    news:[email protected]...
    >
    > Hi all,
    >
    > What is the code to convert text taken from a input text box (on a
    > form) into a number that can be used for manipulation?
    >
    > Thanks
    >
    >
    > --
    > FCC
    > ------------------------------------------------------------------------
    > FCC's Profile:

    http://www.excelforum.com/member.php...o&userid=35888
    > View this thread: http://www.excelforum.com/showthread...hreadid=568900
    >




  4. #4
    NickHK
    Guest

    Re: Code to convert text input to a number

    Ignore this as I misread your "input text box" for an input box.

    NickHK

    "NickHK" <[email protected]> wrote in message
    news:[email protected]...
    > If you use the Application.InputBox instead of VBA.InputBox, you can

    specify
    > a Type:=1 argument, to limit the user to numbers. e.g.
    > Debug.Print VarType(Application.InputBox("Some prompt", , , , , , , 1))
    > 5
    > shows that a double was returned.
    > You still need to check for the Cancel, which =False.
    >
    > NickHK
    >
    > "FCC" <[email protected]> wrote in message
    > news:[email protected]...
    > >
    > > Hi all,
    > >
    > > What is the code to convert text taken from a input text box (on a
    > > form) into a number that can be used for manipulation?
    > >
    > > Thanks
    > >
    > >
    > > --
    > > FCC
    > > ------------------------------------------------------------------------
    > > FCC's Profile:

    > http://www.excelforum.com/member.php...o&userid=35888
    > > View this thread:

    http://www.excelforum.com/showthread...hreadid=568900
    > >

    >
    >




+ 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