ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Userform Help (https://www.excelbanter.com/excel-programming/282600-userform-help.html)

Pete[_13_]

Userform Help
 
I have created a couple userform the calculate a formula,
based on inputed info from the user. In certain situations
the answer needs to be a Dollar value and in others the
calculated number only needs to display 4 numbers past the
decimal point.

How do I cange this code to reflect the two seperate
situations.

Private Sub CommandButton1_Click()
sStr = "#" & Trim(TextBox1) & "#" & Trim(TextBox2) & "#" &
_ Trim(TextBox3) & "#" & Trim(TextBox4) & "#"
sStr1 = Application.Substitute(Application.Substitute
(sStr, "#", ""), ".", "")
If InStr(sStr, "##") = 0 And IsNumeric(sStr1) Then
TextBox5 = (CDbl(TextBox1) * CDbl(TextBox2)) / (CDbl
(TextBox3) * CDbl(TextBox4) * 12)
End If

End Sub

Any help is better than what I got.
Thanks
Pete W

Tom Ogilvy

Userform Help
 
dblVal = (CDbl(TextBox1) * CDbl(TextBox2)) / _
(CDbl(TextBox3) * CDbl(TextBox4) * 12)

TextBox5 = Format(dblVal,"$ #,##0")

or

Textbox4 = Format(dblVal,"0.0000")

--
Regards,
Tom Ogilvy

"Pete" wrote in message
...
I have created a couple userform the calculate a formula,
based on inputed info from the user. In certain situations
the answer needs to be a Dollar value and in others the
calculated number only needs to display 4 numbers past the
decimal point.

How do I cange this code to reflect the two seperate
situations.

Private Sub CommandButton1_Click()
sStr = "#" & Trim(TextBox1) & "#" & Trim(TextBox2) & "#" &
_ Trim(TextBox3) & "#" & Trim(TextBox4) & "#"
sStr1 = Application.Substitute(Application.Substitute
(sStr, "#", ""), ".", "")
If InStr(sStr, "##") = 0 And IsNumeric(sStr1) Then
TextBox5 = (CDbl(TextBox1) * CDbl(TextBox2)) / (CDbl
(TextBox3) * CDbl(TextBox4) * 12)
End If

End Sub

Any help is better than what I got.
Thanks
Pete W





All times are GMT +1. The time now is 12:28 AM.

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