Calculate with app inventor

Hi,
I'm new to App Inventor and need some help...

This is a description what the app should do:
First the variables eb, gesammelt and m are initialized.
When button1 is clicked eb gains its value from the texbox1 and gesammelt and m gains its values from tinydb1.
Then, if eb is smaller as m, the new values for m and gesammelt are calculated.
The values of m and gesammelt are displayed in label3 and label4.
Then the values are stored in tinydb1.

I've got the following situation:
The values of m and gesammelt are not displayed in label3 and label4.
And I get an error message (see attached).
operation + can not accept "12.34"

Because it is my first app I would be very thankful for help.

Greetings,

newapp
blocks (4) blocks (3) blocks (2)

the value of the valueIfTagNotThere socket should be 0 in both cases
Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

hello Taifun!
Thanks a lot for your answer!
I changed both values but the error is still there...
What can I do?

which means the issue occurs while you ae trying to use the add operation to add the 2 values gesammelt and eb
please provide the exact error message

use Do it to debug your blocks, see also tip 4 here App Inventor: How to Learn | Pura Vida Apps
see also Live Development, Testing, and Debugging Tools
Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

hello Taifun,
here is the error message:fehlermeldung
thanks a lot for your help!

Hello newapp,
I guess that what was saying Taifun is that you shall change the "type" of data in the valueIfTagNot There option: you shall use numerical type data (the blue block, instead of the purple ones). The error message you show still refers to string type. So please try to set a 0 value (zero) but change the type.
Hoping it can help.
Tschuess.
image

1 Like

You also might have a non-number sneak in to your calculation through TextBox1.Text.

Instead of eating TextBox1.Text directly, filter it through this expression:

if is a number(TextBox1.Text
then TextBox1.Text
else 0

learn to understand the error message
Unbenannt2

you also might want to clear TinyDB bfore continuing to test...

use Do it to debug your blocks, see also tip 4 here https://puravidaapps.com/learn.php
see also Live Development, Testing, and Debugging Tools
Taifun

Dear all,
I come back to my previous post: if the variables contain string, the sum does not work and raises exactly the error message reported.
On the opposite, if the variables contain numbers, it works. And that's all.
Rgds.

image

Dear community members!
Thanks a lot for your very useful help!
With your help I was able to get the app running.
Thank you...
Greetings newapp

Glad of that. :grinning:
Cheers

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.