# App Lab - How to run code when changing to a new screen?

**URL:** <https://forum.code.org/t/app-lab-how-to-run-code-when-changing-to-a-new-screen/24796>\
**Category:** CS Principles\
**Tags:** applab\
**Created:** [February 13, 2019, 12:31am UTC](https://forum.code.org/t/app-lab-how-to-run-code-when-changing-to-a-new-screen/24796 "2019-02-13T00:31:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrbriggsteach](https://avatars.discourse-cdn.com/v4/letter/m/c77e96/32.png) [@mrbriggsteach](https://forum.code.org/u/mrbriggsteach)\
**Post date:** [February 13, 2019, 12:31am UTC](https://forum.code.org/t/app-lab-how-to-run-code-when-changing-to-a-new-screen/24796/1 "2019-02-13T00:31:26Z")

</div>

Hi,  
My students have made a quiz game. Some of them would like to display a score on the final page. They have set up a variable that gets incremented when the correct answer is pushed. But cannot figure out how to display the score on the final screen.

My idea was to use a label and update the text to the variable, however, I am not sure how to run that code? There does not seem to be an event such as when screen1 is loaded or something.

Thanks in advance,

Craig

---

<div class="post-metadata">

**Author:** ![kaitie\_obryan](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/kaitie_obryan/32/1304_2.png) [@kaitie\_obryan](https://forum.code.org/u/kaitie_obryan)\
**Post date:** [February 13, 2019, 10:41pm UTC](https://forum.code.org/t/app-lab-how-to-run-code-when-changing-to-a-new-screen/24796/2 "2019-02-13T22:41:56Z")

</div>

Hi @mrbriggsteach - it sounds like you have the right idea! Can you share a link to the app here? You can do that by clicking “Share” in the top left corner and taking that URL. I can take a look at it!

KT

---

<div class="post-metadata">

**Author:** ![gjschmidt](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/gjschmidt/32/4922_2.png) [@gjschmidt](https://forum.code.org/u/gjschmidt)\
**Post date:** [February 14, 2019, 2:55pm UTC](https://forum.code.org/t/app-lab-how-to-run-code-when-changing-to-a-new-screen/24796/3 "2019-02-14T14:55:40Z")

</div>

@mrbriggsteach - You might have already figured this out but you can set the text for a text box that is not on the current screen so when you switch to the new screen it’s there. The attached program is a quick example: [https://studio.code.org/projects/applab/-D7HgB9X93vBsvR1KZ4BPxdcsk0udr7b0x02M3U8H28](https://studio.code.org/projects/applab/-D7HgB9X93vBsvR1KZ4BPxdcsk0udr7b0x02M3U8H28)
