Android Question Scientific Calculator, I need help

Carlos Gómez

Licensed User
Can Someone help me with the calculator example with respect to the decimal point , the input method: algebraic and overall this application is as simple as possible . The buttons are created by code.

Thank you very much for your help.


  • ScientificCalculator.txt
    4.5 KB · Views: 101


Licensed User
First of all you need to create a good GUI; your code on one of my emulators:

You should study the documentation (and/or search on site).
Last edited:
Upvote 0


Licensed User
As already suggested by LucaMS you need to improve the layout.
Be aware that TextSize is density independant !
So setting it proportionally to teh view height works only with a density of 1 !
When using pixel values you must use dip values.
To check why the "." doesn't work well put a breakpoint in the code and go through it step by step.
When you post a project post it as a zip file (IDE menu File / Export As Zip).
Upvote 0


Active Member
Licensed User
I don't know exactly wat you mean.

I debug a little the code and I found that when you put a "0." it fails.
I add a line in your code and now it works fine (I think).

Case Else:   
            If Label1.Text <>"0" Then Str =Label1.Text & Str
            If Label1.Text ="0" AND Str="." Then Str =Label1.Text & Str    'line added

Also the text size don't work fine.

Upvote 0

Roger Daley

Well-Known Member
Licensed User

I'm not sure what you are after, but I have been using the code for SCalculator [by Derez] as my B4A training exercise. It is far more complex than your sample code but may be of use as a tutorial.

Alternatively my first attempt, which is a simpilfied hack of Derez's SCalculator code. It may help, it may confuse.

Blind leading the blind.
Newbie leading newbie.

Regards Roger
PS From the comments above, you may want look creating buttons etc with an external graphics program. If you have any experience with the likes of Photoshop, Gimp is a good free alternative but a steep learning curve. at is an easier start.
Upvote 0


Licensed User
It is far more complex than your sample code
The complexity is due to the need to perform operations by the mathematical correct order.
Also the input method is not by keyboard so I had to create an input algorithm by myself.
Upvote 0