Search code examples
app-inventor

How do I perform math using TinyDB? (App Inventor 2)


I am trying to use TinyDB in order to store a value on one screen and display it on another. On the second screen, I want to add 1 to the number stored with TinyDB on the first screen. However, when I try to do this, nothing happens. What am I doing wrong?

Here's my code for the two screens.

Screen1
enter image description here

Screen2 enter image description here


Solution

  • You already loaded the available computers in Screen2.Initialize into label computersAvail.Text. Therefore in the Button1.Click event first add 1 like this

    set computersAvail.Text to get computersAvail.Text + 1
    

    and to store the updated available computers in TinyDB then use the following block

    TinyDB.StoreValue "Computers"
                      get computersAvail.Text
    

    btw. it helps to first do the tutorials to learn the basics of App Inventor...
    also see this link for "the lost souls"...