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

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

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

## All 7 Replies

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

can you provide me a vb code ?

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

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

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") & "%")
``````

very useful thanks.