Help with a calculator app

Hi all, so I am working on a calculator type app that uses a list picker to pick a specific equation where you'll enter the required fields into up to 3 text boxes. I have labels for each text box that are supposed to populate with the appropriate text for each equation to tell you what you need to enter into the text boxes themselves.

So where I am currently stuck is when you pick your equation from the list picker, the labels are just cycling through from the first to the last and not actually the corresponding labels for the equations. Any help/guidance would be greatly appreciated. I've included some screen shots of my blocks. The first few are of my lists and the last one is of blocks for the list picker and labels. Thanks for your help!

The problem with including textbox.text values in a global init is that there is no opportunity for delayed execution. They all happen at init time, with empty text.

You will need some sort of run time expression interpreter, or use your list picker to open one Arrangement per Element, in a lookup table Selection->Arrangement.

This simple example should show you how to set the labels for your textboxes:

You can then use the Selection Index to select the correct formula in the formula list.

You need to "set" the formula list in an event after textbox values have been input by the user, you cannot define that formula list on initialisation (which is why you see a red cross against the formula list variable).


Ah! Thank you so much, my list picker and labels are now working as they should! So what do you recommend for boxes in terms of the formulas so when I input the required values and click the calculate button it will perform the equation? The screen shot is what the designer looks like. So you would click the list picker to choose an equation, when you choose the equation the labels appear to tell you what data needs to be entered in the text boxes and then when you press calculate it will perform the equations and then it will display the result in the results label.

Sorry for all the equations. I am doing this app for a final project for an Intro to app designing class and this is for sure quite a bit more complex than what we've built thus far.

Something like this ?

calcappdemo.aia (3.2 KB)

Okay, so I switched the blocks up for the formulas and this is what it looks like now. I did put in the initialize with the create empty list block up above it.

So now when I go to plug in a value in the text boxes for any one of the equations, this is the error that I am getting. Any thoughts on what it might be?

Possibly an empty textbox ? Either set checks that all textboxes have had a value entered / and/or set all textboxes to 0 (zero). The maths blocks will not work on empty textboxes.

Instead of an indexed list that would execute all formulas, you need an if/then/elseif ladder in the Calculate button Click event that would execute only the appropriate formula, based on the List Picker Selection.

Likewise, The List Picker AdterSelecting event is a good place to put an if/then/elseif ladder to setup Label.Text hints, textbox hints and visibility, Image Pictures, etc. for the selected formula.

So that seems to have done the trick, it just needs the zero in the text boxes and it works. Now It will perform the equation and give me the appropriate results but on equations that only have 1 field to enter I get this error message in the attached screen shot. If I change the 2nd text box to a 1 it won't throw the error which I find to be weird. Could this be a result from what ABG mentioned that as it is right now it executes all formulas? But if it was executing all formulas you would think it wouldn't give the correct answer which isn't the case.

I am building a calculator app that utilizes a list picker to choose an equation and then you can enter a value into the text box(es) and it will give you the result. I've built all of my formulas for said equations but one of them has me a bit stumped. Is there a math block to use that will display a range so if I say put in the number 5 it will multiply it by 2 numbers like 2 and 4 and the result will show 10-20? I tried the min/max block but that didn't work, wasn't sure if there was anything else that might do the trick.

Sorry I am lost what you are trying to do.
More example please

Since this is related to this project I merged your question.

1 Like

So for one of the formulas I want it to display a range so for example if I enter 50 it will multiply that by 4 and 6 and display in my results label the answer 200-300. I'm not sure if that is even possible or if it is what math blocks would you use to do that?

this is just basic math. 50x4 =200, and 50x 6 =300. Why this is not possible?

I am trying to have it be displayed under 1 label as a range, not as 2 separate numbers/equations. So instead of showing it as 200 300 I want it to show it as the range of 200-300.

how about use Text Join block?

The app I am building is a calculator for respiratory therapists and one of the equations is for safe tidal volume ranges for an adult patient in ARDS. my goal is when you input the patient's ideal body weight it would then display the safe tidal volume range you can use for the patient. So in the example I used above if the patient's ideal body weight was 50kg, their safe tidal volume range would be 200-300mL

so this 4 and 6 is fixed? or adjustable?

1 Like

Do the two calculations, then use a text join block to create a string, separating the two numbers with a hyphen.

So this is my issue with this I think, mind you I am toward the end of the semester for my first app design class so I am still fairly new with this, I am using a list picker to choose which equation you want, I have a list of 14 equations at the moment, how could I get it to perform the equation all under one formula? Below is a list of my blocks for the formula list and a screen shot of how the calculator looks itself using one of the other equations I have programmed in there..