How to store input from Textbox as a number rather than a string

I’m trying to pass values to firebase realtime database, the input box has number only enabled. But whenever I enter a number in the Textbox and I pass it to firebase, it stores the number in the following format "# \ #“100” #/# " (ignore the # symbol)

In firebase data will be written in terms of json format only. You cannot change that… While retrieving time you will get it as the way how user or you entered in the text box. So do no worry about the " or / symbols

For more info pls visit here ,

https://firebase.google.com/docs/database/unity/save-data

I’m not able to calculate with the number in python.

It’s returning me “invalid literal for int() with base 10” error, and I think it’s saying, the given data is a text, hence you cannot perform mathematical operations with it.

Post a screenshot of your blocks. Were do you use python ?

I’m running the script on Ubuntu 20. Something.

It’s literally

Initialise var num set value to 0

On text box text changed
Set var num to text box text

On button1 click
Firebase store value tag : number
value to store : var num

Pls try this as said by dora mam.

Meanwhile if you want to integrate Python with firebase pls check up here ( i am not sure, Firebase+Python: How to Integrate Firebase Into Your App)

Never mind, I’ve figured it out with python.

I used “eval” function in python to get rid of the excess ", then used “int” parameter to convert it to a number from string.

1 Like
Write data
Basic write operations

For basic write operations, you can use setValue() to save data to a specified reference, replacing any existing data at that path. You can use this method to:

    Pass types that correspond to the available JSON types as follows:
        String
        Long
        Double
        Boolean
        Map<String, Object>
        List<Object>
    Pass a custom Java object, if the class that defines it has a default constructor that takes no arguments and has public getters for the properties to be assigned.

It’s kodular simplification we can’t choose what variable type we want to write.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.