Re: [Gambas-user] Rounding to 2 decimals

2012-07-27 Thread rocko
Thanks.. On Fri, 2012-07-27 at 21:31 +0300, Jussi Lahtinen wrote: > If you use TextBox to display the result, then you need to convert to > string. > > resultBox.Text = Str(perAmnt) & "%" > > > These should be fairly easy to find from documentation. > > All topics: > http://www.gambasdoc.org/

Re: [Gambas-user] Rounding to 2 decimals

2012-07-27 Thread Jussi Lahtinen
If you use TextBox to display the result, then you need to convert to string. resultBox.Text = Str(perAmnt) & "%" These should be fairly easy to find from documentation. All topics: http://www.gambasdoc.org/help?v3 Keywords: http://www.gambasdoc.org/help/lang?v3 Jussi On 27 July 2012 21:

Re: [Gambas-user] Rounding to 2 decimals

2012-07-27 Thread rocko
AHA! That works, I forgot about using 'Float' If I were to use a textBox to display the result, how would I convert it?? Would it be something like: Val(perAmnt) On Fri, 2012-07-27 at 21:14 +0300, Jussi Lahtinen wrote: > Issue with Round is more complicated. It is floating point precision > pr

Re: [Gambas-user] Rounding to 2 decimals

2012-07-27 Thread Tobias Boege
On Fri, 27 Jul 2012, rocko wrote: > On Fri, 2012-07-27 at 19:49 +0200, Tobias Boege wrote: > > On Fri, 27 Jul 2012, rocko wrote: > > > On Fri, 2012-07-27 at 19:25 +0200, Tobias Boege wrote: > > > > On Fri, 27 Jul 2012, rocko wrote: > > > > > Using '.value instead of .text gives an error: > > > > >

Re: [Gambas-user] Rounding to 2 decimals

2012-07-27 Thread Jussi Lahtinen
Oh, and before using Val() check whether string you got can be converted to number. Dim prmAmnt As Integer Dim totAmnt As Integer Dim perAmnt As Float If IsNumber(prmBox.Text) = True And If IsNumber(totBox.Text) = True Then prmAmnt = Val(prmBox.Text) totAmnt = Val(totBox.Text) perAmnt = Round(

Re: [Gambas-user] Rounding to 2 decimals

2012-07-27 Thread rocko
Ok I just removed the & "%" at the end and the value box is working. But I still cannot get it to round to 2 decimal places. Round((prmAmnt / totAmnt * 100), -2) On Fri, 2012-07-27 at 21:11 +0300, Jussi Lahtinen wrote: > ValueBox doesn't take strings. > So, I suggest to use TextBoxes and do the

Re: [Gambas-user] Rounding to 2 decimals

2012-07-27 Thread Jussi Lahtinen
Issue with Round is more complicated. It is floating point precision problem, which arises from automatic conversion from float to single. You can fix it by changing; Dim perAmnt As Single to Dim perAmnt As Float Jussi On 27 July 2012 21:05, rocko wrote: > On Fri, 2012-07-27 at 19:49 +02

Re: [Gambas-user] Rounding to 2 decimals

2012-07-27 Thread Jussi Lahtinen
ValueBox doesn't take strings. So, I suggest to use TextBoxes and do the conversion properly with Val(). Jussi On 27 July 2012 21:05, rocko wrote: > On Fri, 2012-07-27 at 19:49 +0200, Tobias Boege wrote: > > On Fri, 27 Jul 2012, rocko wrote: > > > On Fri, 2012-07-27 at 19:25 +0200, Tobias Bo

Re: [Gambas-user] Rounding to 2 decimals

2012-07-27 Thread rocko
On Fri, 2012-07-27 at 19:49 +0200, Tobias Boege wrote: > On Fri, 27 Jul 2012, rocko wrote: > > On Fri, 2012-07-27 at 19:25 +0200, Tobias Boege wrote: > > > On Fri, 27 Jul 2012, rocko wrote: > > > > Using '.value instead of .text gives an error: > > > > "Unknown symbol "value" in class TextBox" > >

Re: [Gambas-user] Rounding to 2 decimals

2012-07-27 Thread Tobias Boege
On Fri, 27 Jul 2012, rocko wrote: > On Fri, 2012-07-27 at 19:25 +0200, Tobias Boege wrote: > > On Fri, 27 Jul 2012, rocko wrote: > > > 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: > > >

Re: [Gambas-user] Rounding to 2 decimals

2012-07-27 Thread rocko
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(

Re: [Gambas-user] Rounding to 2 decimals

2012-07-27 Thread rocko
On Fri, 2012-07-27 at 19:25 +0200, Tobias Boege wrote: > On Fri, 27 Jul 2012, rocko wrote: > > 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 calcula

Re: [Gambas-user] Rounding to 2 decimals

2012-07-27 Thread Tobias Boege
On Fri, 27 Jul 2012, rocko wrote: > 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 >

Re: [Gambas-user] Rounding to 2 decimals

2012-07-27 Thread rocko
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

Re: [Gambas-user] Rounding to 2 decimals

2012-07-27 Thread Fabien Bodard
2012/7/27 Ricardo Díaz Martín > Yes, gambas convert them but I you can have some problems with "-", "." and > "," symbols if you are using formatted numbers > it's true > 2012/7/27 Fabien Bodard > > > Le 27 juil. 2012 08:33, "Ricardo Díaz Martín" < > oceanosoftlapa...@gmail.com > > > > > a écrit

Re: [Gambas-user] Rounding to 2 decimals

2012-07-27 Thread Ricardo Díaz Martín
Yes, gambas convert them but I you can have some problems with "-", "." and "," symbols if you are using formatted numbers 2012/7/27 Fabien Bodard > Le 27 juil. 2012 08:33, "Ricardo Díaz Martín" > > a écrit : > > > > Hi rocko > > > > As you can read this http://gambasdoc.org/help/lang/round you

Re: [Gambas-user] Rounding to 2 decimals

2012-07-26 Thread Fabien Bodard
Le 27 juil. 2012 08:33, "Ricardo Díaz Martín" a écrit : > > Hi rocko > > As you can read this http://gambasdoc.org/help/lang/round you have to > put perAmnt > = Round((prmAmnt / totAmnt * 100), -2). In addition you'd have to convert > the Text to float on before to do the division to avoid errors

Re: [Gambas-user] Rounding to 2 decimals

2012-07-26 Thread Ricardo Díaz Martín
Hi rocko As you can read this http://gambasdoc.org/help/lang/round you have to put perAmnt = Round((prmAmnt / totAmnt * 100), -2). In addition you'd have to convert the Text to float on before to do the division to avoid errors or using ValueBox. Regards, Ricardo Díaz 2012/7/27 LeszekK > Valu

Re: [Gambas-user] Rounding to 2 decimals

2012-07-26 Thread LeszekK
ValueBox1.Value = perAmnt 2012/7/27 LeszekK : > ValueBox1.Value = perAmnt & "%" -- Serdecznie pozdrawiam, Leszek Kubiszewski -- Live Security Virtual Conference Exclusive live event will cover all the ways today's se

Re: [Gambas-user] Rounding to 2 decimals

2012-07-26 Thread LeszekK
'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

[Gambas-user] Rounding to 2 decimals

2012-07-26 Thread rocko
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 /