Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA userform jcheko Excel Worksheet Functions 1 April 24th 08 08:38 PM
userform carwincarber New Users to Excel 0 October 23rd 05 06:59 PM
userform Tom Ogilvy Excel Programming 1 September 2nd 03 10:12 PM
userform Antonov Excel Programming 1 September 2nd 03 04:25 AM
Userform help Lorenzo Excel Programming 1 July 25th 03 01:05 PM


All times are GMT +1. The time now is 05:12 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"