View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Format textbox on exit

Mike,

Don't do it. Add a button to accept the value and format it

Private Sub cmdAnnualInterest_Click()
tbAnnualInterest.Text = Format(tbAnnualInterest.Text / 100, "0.0000%")
End Sub

and just tab back in if not okay.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Michael Malinsky" wrote in message
oups.com...
I have the following:

Private Sub tbAnnualInterest_Exit(ByVal Cancel As
msforms.ReturnBoolean)

tbAnnualInterest = Format(tbAnnualInterest / 100, "0.0000%")

End Sub


which works fine the first time a value (a percentage entered as 4.9
vs. .049) is entered into the textbox. However, if the textbox is
entered and exited without entering a new value, I get a Type mismatch
error. I've tried using various combinations of Val and/or CStr and
anything else I thought might be useful.

Any suggestions, as always, are greatly appreciated.

TIA
Mike