Userform Help

  • Thread starter Thread starter Pete
  • Start date Start date
P

Pete

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
 
dblVal = (CDbl(TextBox1) * CDbl(TextBox2)) / _
(CDbl(TextBox3) * CDbl(TextBox4) * 12)

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

or

Textbox4 = Format(dblVal,"0.0000")
 
Back
Top