Format number (percent) in textbox

Y

YSK

Hello,

I've got a textbox and i do want to set its format to 'Percent', in that way
the user will simply type the number (eg: 10 for 10%).

But my problem is the number given by user will be multipled with 100, it
means that if user entered 10% the value in the textbox will be 1000%.

How can I deal with this problem?

Thank in advance

YSK.
 
N

Nikos Yannacopoulos

Use the Before Update event of your textbox to run a single line of code:
Me.txtBoxName = Me.txtBoxName / 100

replacing txtBoxName with the actual name of the textbox. This way when the
user enters 10, it will be automatically be converted (and saved in the
table, if bound) to 0.1, and dispayed as 10%.

HTH,
Nikos
 
Y

YSK

Hello,

I really appreciate your help. It's one of pretty good way to deal with my
problem.

I finally found another solution, it's Format(Me.txtBoxName.value, 0.00) &
"%"

I think both of solutions provided are quite useful.

YSK.
 
M

Marshall Barton

YSK said:
I've got a textbox and i do want to set its format to 'Percent', in that way
the user will simply type the number (eg: 10 for 10%).

But my problem is the number given by user will be multipled with 100, it
means that if user entered 10% the value in the textbox will be 1000%.


Instead of using the Percent format (which is pretty much
that same as 0.00%), set the text box's Format property to

0.00\%
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top