# FomatPercent

I have the following vb statement:

Dim percentage As Integer = (Me.lblAGR.Text / Me.lblBGR.Text * 100 - 100) --> returns 62

How can I return 62% and keep percentage as integer?
Other option would be to store as string and when I update the value replace % with '' and convert back to integer

I tried FormatPercent

ASP.NET

Last Comment
abel

8/22/2022 - Mon
David Robitaille

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
abel

There must be a location where you want to show the percentage. Depending on what you are using, you can use the format specifiers there (i.e., on a label) to show the percent. An integer is only the number and will not contain anything else then digits.
abel

Note that using the percentage in the format specifier expects a value between 0 an 1 (in other words, it will multiply with 100). So, you can do the following:

lblPercent.Text = (percentage / 100).ToString("0%")

On your webpage, you need the following:

<asp:Label runat="server" ID="lblPercent" />
JessyRobinson1234

davrob60,
Tried that and it's a step in the right direction, the result is: 62.978963464422%. How can I do rounding and not display decimals (63%)
Thanks
SOLUTION
abel

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
David Robitaille

String.format("{0:f0}%", percentage)
http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx
abel

Alternatively, you can consider this:

lblPercent.Text = percentage & "%"

easier is hardly possible, sometimes we do not need complex formatters to get our task done ;)
JessyRobinson1234