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

Recommended Answers

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.

if your prob is solved please mark this thread solved , regards

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.