We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now


How to clalculate percent difference between two vlaues

Medium Priority
Last Modified: 2012-06-22
Say I have two labels on my page:

Label 1 has a value of 100
Label 2 has a value of 140

How do I calculate the % difference between these 2 values in VB?
Watch Question

Top Expert 2009

That should be:

dim percentage As Integer = Abs(val1 / val2 * 100 - 100)

Top Expert 2009
To go from a label to a number, use:


So, the whole code may become:

Dim percentage As Integer = Abs(Integer.Parse(Label1.Text) / Integer.Parse(Label2.Text) * 100 - 100)

Of course, the order matters. From 100 to 140 is a 40% increase, from 140 to 100 is 28.5% decrease. You may remove ABS if you want to know whether it is increase or decrease:

From 140 to 100:

100 / 140 = 0.7143
0.7143 * 100 = 71.43
71.43 - 100 = -28.57

From 100 to 140

140 / 100 = 1.4
1.4 * 100 = 140
140 - 100 = +40

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts


Will give you the % difference between them in terms of label1%
Top Expert 2009

That'd be the same road to heaven, differently formulated ;)
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.