How can I convert text to "number"?

But it works, isn't it?
What did not work for you?

I have used this method in my app and have never faced any issues

2 weeks ago I and a few classmates tried using a string directly as a number. And it gave me an error message.

Could you show the error?

I want to

image

Label7(text) →  number        

How can I ?

I don't exactly remember, neither do I have any screenshots

Is there any specific reason to covert it to number? Because as I showed, all operations work good with a text string containing only numbers

text "17" → number "17"

How ????

... and again:

So where is the problem and what is the goal?

If you must:

image

but as previously said, the string will be treated as a number in mathematical operations. However, the number may be treated differently in (online databases) - e.g. firebase/mySQL/sqLite - but this will depend on how you transfer it.

3 Likes

May we know?

maybe you mean like this :

blocks

Or maybe something like this :

@mal_ju never mentioned comparing of the spelling and numeral of any number!
@Salman_Dev kindly do not go off topic

Unlike lower level languages, AI2 has Duck Typing for math operations.

I think he means to convert the text string image

to a number string image

2 Likes

i have the same question. if i put number "1" on the textbox the answer on the label will be converted to "one". "-1" will be "negative one". can you help me guys? thanks

Are you talking about speech output?

Are you complaining about this happening, or are you asking for a way to make this happen?

its good now sir. I already have a solution. thanks

please share the solution here and close this topic. Thank you :innocent:

Thank you! This helped me. I was scared that numbers in text strings will be treated like in Small Basic, which means that "100" + "55" = "10055".

1 Like