Consulting

Results 1 to 5 of 5

Thread: Display decimal values in a text box

  1. #1
    VBAX Regular
    Joined
    Aug 2005
    Posts
    79
    Location

    Display decimal values in a text box

    On my UserForm, I want to display decimal values in a text box. How do I do that?

    Thanks

  2. #2
    VBAX Contributor
    Joined
    Dec 2004
    Posts
    122
    Location
    TextBox1 = Format(Range("a1"), "#0.#####")

  3. #3
    VBAX Regular
    Joined
    Aug 2005
    Posts
    79
    Location
    I am not using data from a spreadsheet. I am getting the data from the UserForm from input from the user. Once I have the data, I make some calculations and display it on the form but I want to format and display decimal figures.

    Thanks

  4. #4
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    You can still use the Format method as shown above ...

    Me.TextBox1.Value = Format(iVal, "#0.##")
    .. where iVal is your value/variable.

    If you need mroe help than that, please post your code or zip/upload a sample file.

  5. #5
    VBAX Expert
    Joined
    Feb 2005
    Posts
    929
    Location
    Quote Originally Posted by SailFL
    I am not using data from a spreadsheet. I am getting the data from the UserForm from input from the user. Once I have the data, I make some calculations and display it on the form but I want to format and display decimal figures.

    Thanks
    Assuming your initially get input (stuffed in the variable Val) from TextBox1, do some operations on Val and then display the result in TextBox2, the code might look something like this:

    Dim Val as Single
    '     other statements
    Val = Me.Textbox1.Value
    '     calculations on Val
    Me.Textbox2.Value = Format(Val,"#0.###")
    "It's not just the due date that's important, it's also the do date" [MWE]

    When your problem has been resolved, mark the thread SOLVED by clicking on the Thread Tools dropdown menu at the top of the thread.

Posting Permissions

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