PDA

View Full Version : [SOLVED] Display decimal values in a text box



SailFL
08-19-2005, 11:53 AM
On my UserForm, I want to display decimal values in a text box. How do I do that?

Thanks

gsouza
08-19-2005, 12:18 PM
TextBox1 = Format(Range("a1"), "#0.#####")

SailFL
08-19-2005, 01:12 PM
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

Zack Barresse
08-19-2005, 01:16 PM
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.

MWE
08-19-2005, 02:07 PM
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.###")