Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Add the $.00 pennies if no value is present after the whole number?
Hey all!
The idea is the following... A person enters a value in to a textbox. Based on the valued entered it may or may not have change... this is simply for uniformity in the database. I'd like the following to happen... End User types "$9.99" into textbox - nothing happens as it does have a value after the period. End User Types "$9" into textbox on exit the text box adds the ".00" so it comes out to be "$9.00" Any help is greatly appreciated!! |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Add the $.00 pennies if no value is present after the whole number?
In a suitable event use
TextBox1.Value=Format(TextBox1.Value,"#0.00") NickHK wrote in message ups.com... Hey all! The idea is the following... A person enters a value in to a textbox. Based on the valued entered it may or may not have change... this is simply for uniformity in the database. I'd like the following to happen... End User types "$9.99" into textbox - nothing happens as it does have a value after the period. End User Types "$9" into textbox on exit the text box adds the ".00" so it comes out to be "$9.00" Any help is greatly appreciated!! |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Add the $.00 pennies if no value is present after the whole number?
Try something like the following. When focus moves away from the text box to
another control, the text in the text box will be formatted with two decimal places. The KeyPress event prevents the user from inputting alpha characters. Only 0-9, '.', and '-' are allowed. Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) With Me.TextBox1 If Len(.Text) = 0 Then .Text = "0.00" Else .Text = Format(.Text, "#,##0.00") End If End With End Sub Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger) Select Case KeyAscii Case Asc("0") To Asc("9") Case Asc("-") If InStr(1, Me.TextBox1.Text, "-") 0 Or Me.TextBox1.SelStart 0 Then KeyAscii = 0 End If Case Asc(".") If InStr(1, Me.TextBox1.Text, ".") 0 Then KeyAscii = 0 End If Case Else KeyAscii = 0 End Select End Sub -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com (email address is on the web site) wrote in message ups.com... Hey all! The idea is the following... A person enters a value in to a textbox. Based on the valued entered it may or may not have change... this is simply for uniformity in the database. I'd like the following to happen... End User types "$9.99" into textbox - nothing happens as it does have a value after the period. End User Types "$9" into textbox on exit the text box adds the ".00" so it comes out to be "$9.00" Any help is greatly appreciated!! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
adding up number of people present at certain times | Excel Worksheet Functions | |||
Why is my sum total a couple pennies off from what it should be? | Excel Discussion (Misc queries) | |||
How can I add present month, as number, to an header in excel? | Excel Discussion (Misc queries) | |||
How to count the number of cells highlighted using Conditional Formatting feature present in Format Menu of Excel??? | Excel Programming | |||
How can I count number of sheets present in a workbook? | Excel Discussion (Misc queries) |