'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 <sunblast...@gmail.com>:
> 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@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>



-- 
Serdecznie pozdrawiam,

Leszek Kubiszewski

------------------------------------------------------------------------------
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@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user

Reply via email to