How can I convert text to "number"?

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:

1 Like

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

Although AI2 does an amazingly wonderful job of translating (invisibly) strings-numbers-strings, there still times like when exchanging with Google Charts or Google Sheets (and probably others) that the translation must be made.

:musical_note:Wouldn't It Be Nice :musical_note: (Beach Boys 1966) :musical_note:

WouldntItBeNice

Easy enough....

image

2 Likes

Hello.
I had the problem of receiving data (numbers) from an Arduino trough Bluetooth connection appearing as strings.
The solutions that i found here didn't solved my problem so I've continued researching and i came up with a solution that might help others that may come here too.

I've set a clock to read the data from the bluetooth every second and I've used a label to display the text received from the Bluetooth, because i only needed 4 characters at a time I've used the number 4 in the "number of bytes".
Then i used the label text, that was in fact a number as a string, using the "label.text" block and the data could finally be used as a number for calculations.

1 Like