ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Decimal Places in TextBox (https://www.excelbanter.com/excel-programming/375131-decimal-places-textbox.html)

AMY Z.

Decimal Places in TextBox
 
Hi,
I need to set a certain number of decimal places in a TextBox. Is there a
way to do this with code or in a property?
The TextBox is on a Form. The TextBox is used to display a number Value.
It is not linked to anything outside the form, IE: cells on a worksheet etc.

Thank you,
Amy

Paul Mathews

Decimal Places in TextBox
 
Amy, you could do something like this:

TextBox.Text = VBA.FormatNumber(Value,2)

where, in this example, 2 represents the number of decimal places that will
be shown in the text box.

"AMY Z." wrote:

Hi,
I need to set a certain number of decimal places in a TextBox. Is there a
way to do this with code or in a property?
The TextBox is on a Form. The TextBox is used to display a number Value.
It is not linked to anything outside the form, IE: cells on a worksheet etc.

Thank you,
Amy


AMY Z.

Decimal Places in TextBox
 
Hi Paul,
Thank you for taking time to answer my question.
It doesn't work. It doesn't show an error, but won't display anything.
Do you know where I should enter the code?
Do I need to declare too? Using Dim?
This is what I have:
Private Sub TextBox3_Change()
TextBox3.Text =VBA.FormatNumber(Value,2)

I'm just learning how to program.
Thanks again if you come back to this post,
Amy

"Paul Mathews" wrote:

Amy, you could do something like this:

TextBox.Text = VBA.FormatNumber(Value,2)

where, in this example, 2 represents the number of decimal places that will
be shown in the text box.

"AMY Z." wrote:

Hi,
I need to set a certain number of decimal places in a TextBox. Is there a
way to do this with code or in a property?
The TextBox is on a Form. The TextBox is used to display a number Value.
It is not linked to anything outside the form, IE: cells on a worksheet etc.

Thank you,
Amy



All times are GMT +1. The time now is 06:33 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com