Android Question Scientific Calculator, I need help

Carlos Gómez

Member
Licensed User
Longtime 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.
 

Attachments

  • ScientificCalculator.txt
    4.5 KB · Views: 179

LucaMs

Expert
Licensed User
Longtime User
First of all you need to create a good GUI; your code on one of my emulators:
upload_2014-11-9_18-51-42.png


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

klaus

Expert
Licensed User
Longtime 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

JoanRPM

Active Member
Licensed User
Longtime 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).

B4X:
Case Else:   
            If Label1.Text <>"0" Then Str =Label1.Text & Str
            If Label1.Text ="0" AND Str="." Then Str =Label1.Text & Str    'line added
      Num1=Str.Replace("Infinity","")

Also the text size don't work fine.

Regards.
 
Upvote 0

Roger Daley

Well-Known Member
Licensed User
Longtime User
Carlos,

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.
http://www.b4x.com/android/forum/threads/scalculator.6832/

Alternatively my first attempt, which is a simpilfied hack of Derez's SCalculator code. It may help, it may confuse.
http://www.b4x.com/android/forum/threads/abcalculator.43558/

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. Paint.net at Download.com is an easier start.
 
Upvote 0

derez

Expert
Licensed User
Longtime 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
Top