We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,624 Members — Technology Publication meets Social Media

# convert an integer value to percentage

how i can convert an integer value to percentage value (%) , using vb.net

3
Contributors
7
Replies
2 Days
Discussion Span
9 Months Ago
Last Updated
9
Views
Question
HibaPro
Junior Poster
126 posts since Jun 2012
Reputation Points: -3
Skill Endorsements: 0

i think you have to convert your int value first in decimal value and after that make calculations and then just convert your decimal value to string and concatinate it with "%" string.

Regards

M.Waqas Aslam
Master Poster
743 posts since Aug 2011
Reputation Points: 50
Skill Endorsements: 2

can you provide me a vb code ?

HibaPro
Junior Poster
126 posts since Jun 2012
Reputation Points: -3
Skill Endorsements: 0

A percentage of what? Are you having problems with the calculation or with the conversion (formatting) for display?

Reverend Jim
Carpe per diem
Moderator
3,590 posts since Aug 2010
Reputation Points: 561
Skill Endorsements: 32

i have a problem of both , can u help me?

HibaPro
Junior Poster
126 posts since Jun 2012
Reputation Points: -3
Skill Endorsements: 0

Let's say you have a group of 147 people and 36 are female. That means that the fraction of people who are female is 36/147. The percentage of females is one hundred times that. So

``````Dim people As Integer = 147
Dim female As Integer = 36

Dim percent As Double = 100.0 * female / people

'format as floating point with two decimal places

MsgBox(percent.ToString("F2") & "%")
``````
Reverend Jim
Carpe per diem
Moderator
3,590 posts since Aug 2010
Reputation Points: 561
Skill Endorsements: 32

very useful thanks.

HibaPro
Junior Poster
126 posts since Jun 2012
Reputation Points: -3
Skill Endorsements: 0

M.Waqas Aslam
Master Poster
743 posts since Aug 2011
Reputation Points: 50