View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Jan Karel Pieterse Jan Karel Pieterse is offline
external usenet poster
 
Posts: 535
Default Formatting for Numbers & Currency in textbox

Hi Dugless,


This appeared to work however when a certain amount of memory was used
(or when the PC felt like it) this created an infinite loop. When you
look at it that makes sense that it loops (the change in format sets
off the change event). Interestly when you step through it does not
loop.

You can format on the exit (or some other event) but the idea was to
assist with ENTRY of the large numbers.

Any ideas??


Declare a variable at the top of the form's module:

Dim bDisableEvents as Boolean

Now in your change event:

Private Sub t_salary_Change()
If bDisableEvents Then Exit Sub
bDisableEvents=True
t_salary.Value = Format(t_salary.Value, "$#,##0")
bDisableEvents=False
End Sub


Regards,

Jan Karel Pieterse
Excel MVP
www.jkp-ads.com