Fractions Caculator
Posted
#1
(In Topic #310)
Regular

Posted
Guru


By grouping your buttons 0 to 9 I have managed to reduce 50 lines down to 3. See attached
There is no need to set Boolean values to False on starting your program as they are False by default.
You can declare the value of variables in one go. Variables of the same type can be declared in one line.
or
Code (gambas)
Code (gambas)
- TextBox1.Text = TextBox1.Text & KeyNum
Code (gambas)
- TextBox1.Text &= KeyNum
2 + [Inch] 2 =
I also changed the Form somewhat to make it expandable.
I hope it helps.
Posted
Regular

Posted
Regular

Posted
Regular

Posted
Guru


Posted
Regular

Posted
Regular

Posted
Guru


Sorry but I think I have found a bug here. I was trying to divide ½ by ¼ and got this: -
The error occurs at line 427.
<IMG src="https://www.cogier.com/gambas/CalcError.png">
</IMG>
Posted
Regular

Posted
Guru


1/. The menu items don't work. The code should be as below: -
2/. I tried 1/2 divided by 9/32. The program failed at FracCalc Line 426 (Sum = ValueToConvert). Sum is an Integer and ValToConvert is a String. The answer should be 1 & 7/9.
3/. I tried 1 divided by 8/16. The program failed at FracCalc Line 405 (FirstFrac = (WN1 + Numerator1 / Denominator1)) with a Divide by zero error. The answer should be 2.
Hope that helps.
Posted
Regular

Posted
Regular

Posted
Guru


Your program seems to work as expected now. I took the liberty of remaking the 'ConvChart' complete with a search.
Hope it is of use.
Posted
Regular

Posted
Enthusiast

1/2 + 1/2 -> Type mismatch: wanted float got string instead : 2 + 3/3=3 is correct
pushing 9 left field -> 1
123456789 X 9=98765424 (never ever) galculator gives me 1111111101
so IF that thing IS calculating i need a second calculator to proof the result … nice
Posted
Regular

1/2 + 1/2 -> Type mismatch: wanted float got string instead : 2 + 3/3=3 is correct
pushing 9 left field -> 1
123456789 X 9=98765424 (never ever) galculator gives me 1111111101
so IF that thing IS calculating i need a second calculator to proof the result … nice
Sorry to say I can not duplicate your problem with 1/2+1/2 as it comes out as 1 in Arch Linux. This program was never meant to be use as a standard calculator although it can for normal usage. Taking something like 123456789 X 9 is just a Lucretius example to prove that the calculator is no good. If galculator serves you well then you have no need for this program, then don't use it. Others may find it useful and use it. How ever I did find one small overlooked problem and fixed it. By the way 3/3 is not a normal fraction used in construction. Construction fractions are based in 64ths. Look at the conversion chart and you will see what I mean. Personally I don't mind people finding things amiss with the program, but constructively. Besides I only meant that Charlies mod to my program made the conversion chart perfect and not the whole program. The fix will be in the first post for those who want it.
Posted
Guru


<IMG src="https://www.cogier.com/gambas/half.png">
</IMG>
Posted
Regular

Code (gambas)
1 guest and 0 members have just viewed this.




