Whoisit

Here's my code,

dim decPercent as Decimal
decPercent = (pbxResize.Width / pbxResize.Image.Width) * 100
tssSize.Text = "Percent = " & decPercent.ToString

I get answers something like 41.7367345283
I want the answer rounded up or down, if possible, or just to display 41 .

Thanks for looking
Graham



Re: Visual Basic Express Edition Playing the Percentages?

AndrewVos

You can use CInt() or Math.Round().

The first just converts the number to an integer so you would just see 41.

The second can be set to round to a certain number of decimal places.






Re: Visual Basic Express Edition Playing the Percentages?

Dave299

For the record CInt() rounds, Int() gives just the integer part.

Dim D As Decimal = 41.7D

MessageBox.Show(CInt(D).ToString)

MessageBox.Show(Int(D).ToString)





Re: Visual Basic Express Edition Playing the Percentages?

Whoisit

Andrew/Dave,
Thanks for clearing that up for me, it has worked a treat.

Will remember for future use.

Graham




Re: Visual Basic Express Edition Playing the Percentages?

AndrewVos

Ahh, thats something worth noting Dave.

Didn't know that! Here I am typing Math.Round and most probably a CInt around it :) Thanks!

Oh, and it's a pleasure.