Click here to Skip to main content
15,892,537 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
Hi guys,
How to display the input value in the text box as percentage format.
Posted
Updated 4-Apr-21 21:10pm

1 solution

Do you want to force that as a mask? If so you could use a MaskedTextBox with ##.##% as mask, although that won't allow 100.00 as input.
 
Share this answer
 
Comments
waqi19 21-Feb-11 20:22pm    
Actually i ahd an assignment everything is done and i just wanted to show the discount percentage in percentage format but when i put the command as: dim FirstDiscountPercent as single
FirstDiscountPercent=Csng(txt.FDiscPercent.text)
txt.FDiscPercent.text=FormatPercent(FirstDiscountPercent)
when i debug and put the valuess it shows 20% as 2000.00%
Nish Nishant 21-Feb-11 20:25pm    
That's by design. FormatPercent will convert the number to a percentage by multiplying by 100. If you are passing the converted percentage, then you need to divide by 100 to make up for this multiplication. It may be far easier to append a % character :-)
waqi19 21-Feb-11 20:27pm    
how u do that % character?
Nish Nishant 21-Feb-11 20:30pm    
I used an auto-converter to convert C# to VB, so I am not sure if this syntax will work:

txt.FDiscPercent.text = disCountPercent.ToString + "%"
waqi19 21-Feb-11 20:37pm    
its alrite i did the otherway u told me and it worked!!!
thanks for your help

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900