ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Two decimals (https://www.excelbanter.com/excel-programming/402391-two-decimals.html)

Trine Andreassen

Two decimals
 
Can anyone pls help me... How do I get two decimals behind the input
and output number in the textboxed in my coding in VBA in th most easy
way possible....? Have tried the Format "0.00" as someone suggested on
the website here, but it did not work and I am not sure I am placing
it in the right spot...

Any suggestions would me welcome!

Thanks
Trine

Incidental

Two decimals
 
Hi Trine

I'm not sure what you are trying to do exactly but the code below
might help you with your problem. I set up a userform with two
textboxes and a button to control the code, if a whole number is added
to the first textbox when you click the button it will convert the
number in textbox1 to a double and also add the number as a double in
the second textbox.

Option Explicit

Dim MyNum As Double

Private Sub CommandButton1_Click()

MyNum = TextBox1.Value

TextBox2.Value = Format(MyNum, "0.00")

TextBox1.Value = Format(MyNum, "0.00")

End Sub

I hope this is of some help to you

Steve


All times are GMT +1. The time now is 02:56 AM.

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