[Gambas-user] Rounding to 2 decimals

LeszekK lknetpl at ...626...
Fri Jul 27 02:05:49 CEST 2012


'Do not use textboxes for mathematical calculations

Dim prmAmnt As Integer
Dim totAmnt As Integer
Dim perAmnt As Single

prmAmnt = prmBox.value 'valuebox! not textbox
totAmnt = totBox.value 'valuebox! not textbox
perAmnt = Round((prmAmnt / totAmnt * 100), 2)
ValueBox1.Value = perAmnt & "%"

I not tested the code but it should work.

2012/7/27 rocko <sunblaster5 at ...626...>:
> Trying to get my result to just 2 decimal places using the 'Round"
> function but it' not working for me.
> This code gives a result of 0% ???
>
> Code:
>   Dim prmAmnt As Integer
>   Dim totAmnt As Integer
>   Dim perAmnt As Single
>
>   prmAmnt = prmBox.Text
>   totAmnt = totBox.Text
>   perAmnt = Round((prmAmnt / totAmnt * 100), 2)
>
>   TextLabel1.Text = perAmnt & "%"
>
>
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>



-- 
Serdecznie pozdrawiam,

Leszek Kubiszewski




More information about the User mailing list