Click here to Skip to main content
15,908,111 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to add percent sign in textbox after entering value .

.. ex 15%

What I have tried:

i tried by using value.tostring("p")

its stored in float datatype
Posted
Updated 19-Mar-20 6:26am

1 solution

VB.NET
value.ToString("P")
will actually display the value as a percentage:
value   display
0.15    15%
15      1500%
If your goal is to transform 15 to 15%, then you first have to divide the value by 100:
VB.NET
theTextBox.Text = (value / 100).ToString("P")
 
Share this answer
 
Comments
Chinnu2020 19-Mar-20 12:58pm    
while saving does not that percentage also save?

Iam using ef
.Per = c.PComplete,
phil.o 19-Mar-20 13:33pm    
Sorry, I don't undersand your concern. Whatever the value, it will be saved. I you want to save a 15% value, then the float value you have to save is 0.15. Do not confound the value (0.15) with its string representation (15%).
Chinnu2020 19-Mar-20 14:40pm    
sorry for that.. what ever the value which is stored in database while displaying just we need to add percent sign and show in textbox.
phil.o 19-Mar-20 15:39pm    
Again: just save 0.15 as value in the database, and display it as percentage if you need.

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