Turn a string into a number

Hello to anyone reading i am trying to make an app and one of its features is that you can put a number in the text box and if you want you can then use the built in buttons to cycle to the next one or the number that is before the number you input but i am always getting an error when i am trying to use that feature my guess is that the text box isnt a number so the app freaks out when i do that

change it to number from designer

Hi Fusion,
Try using this approach,


Set InputType to Number: 5

next_number.Click

previus_number.Click

TextBox_RoomNumber.OnTextChange

In this case if TextBox_RoomNumber.isEmpty there is no need to change the TextBox_RoomNumber.Text value.

  • If value.isEmpty set Room_Number to 1

  • If there are dots or commas replace them and save the value in local value
    (16,64 = 1664 , 345.6 = 3456)

  • Set TextBox_RoomNumber.Text to the new formatted value

  • Move the cursor to the end

  • Set the value of Room_Number to value

dumb question i found the set text box input type but i cant find the number box anywhere do i need to add it in text

1 Like

Here is your answer :smiley:
.
blocks (12)
Just add the block at the top of your button click event or when screen.init.
If helpful, mark as solution :white_check_mark:

In the Designer screen, by selecting the TextBox you want to use in the Properties section on the right you have all the settings of that TextBox including InputType.

It is not very correct to set it in Screen1.Initialize or with each click on the next and previous buttons.

So i guess i was too quick to press the solution button well none of theses suggestions seemed to work rn my code looks like this including a fail safe so the app can work even if the text is not a number atleast it should but i am still getting an error

the above image is the code that i am currently using to make the both buttons work and below ill attach photos of both the properties section and the error i am encountering

I’ll send the error on an other post.

you are adding a component to a number.

you have to set


set global Room_Number to Room_Number.Text
immagine