PC Review


Reply
Thread Tools Rate Thread

Add the $.00 pennies if no value is present after the whole number?

 
 
Shaka215@gmail.com
Guest
Posts: n/a
 
      27th Feb 2007
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 With Quote
 
 
 
 
NickHK
Guest
Posts: n/a
 
      27th Feb 2007
In a suitable event use
TextBox1.Value=Format(TextBox1.Value,"#0.00")

NickHK

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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 With Quote
 
Chip Pearson
Guest
Posts: n/a
 
      27th Feb 2007
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)




<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Combo Box error when Auto Number present Stacey Crowhurst Microsoft Access Forms 7 3rd Feb 2009 11:56 PM
adding up number of people present at certain times =?Utf-8?B?YmFtYm9vemxlZA==?= Microsoft Excel Worksheet Functions 4 18th Sep 2007 09:02 AM
Make a present number field that automatically increments by 1 =?Utf-8?B?Q2hyaXM=?= Microsoft Access Database Table Design 4 15th Sep 2007 11:08 AM
Re: How can I add present month, as number, to an header in excel? Gord Dibben Microsoft Excel Misc 0 21st Dec 2006 08:23 PM
How can I count number of sheets present in a workbook? =?Utf-8?B?SW1yYW4=?= Microsoft Excel Misc 1 6th Oct 2006 11:06 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:20 PM.