[Gambas-user] Rounding to 2 decimals

rocko sunblaster5 at ...626...
Fri Jul 27 19:19:30 CEST 2012


Using '.value instead of .text gives an error:
"Unknown symbol "value" in class TextBox"

On Fri, 2012-07-27 at 02:05 +0200, LeszekK wrote:
> '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 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 at lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/gambas-user
> >
> 
> 
> 






More information about the User mailing list