Using input-box for numbers

Twine Version: 2.3.16
Story Format: Harlowe 3.2.3

So let’s say I want to store some numbers in a variable but I also want to make some mathematical operations with that variable as well. For example, I put some amount of money in a variable and I want to add two more to the amount I put there later, is this possible in harlowe? From what I understood you can only put strings to an input-box. But my variable has to be a number, what should I do?

(set: $moneyInBank to 0)
...
(input-box:2bind $moneyInBank,"X",1)
...
(set: $moneyInBank to it + 2)

By default any value entered into a HTML input field is turned into a String value.
eg. when you enter the numerical characters 123 the value by default is converted into the String “123”.

So if you want to use the entered value as a number then you need to use the (num:) macro to obtain a numerical copy of that value.

warning: Without using JavaScript, there is no way to force the end-user into entering only numerical characters (eg. 1-9, and 0) into the input field. This can cause issues when trying to convert the entered value into a number, because the (num:) macro will throw an error if it encounters any non numerical characters in the value it is converting.

(set: _amount to (str: $moneyInBank))
(input-box: bind _amount, "X", 1, _amount)
(link: "Submit")[
	(set: _amount to (num: _amount))
	(set: $moneyInBank to _amount)
]

Thank you! That is more than enough for me.