Android Question Use formula in string to calculate

Pedro Caldeira

Active Member
Licensed User
Longtime User
Hello guys,
Is there any way to perform a calculation with the elements in a string

for instance, i have "2x10/20" it can be any other calculus, like "(234/403)-20*50" but they are string
can I somehow convert them to numbers to perform the operations ?

Thanks
 

Mahares

Expert
Licensed User
Longtime User
The number passed needs to be a valid number, it won't work if you pass a string.
Steve: Could you please give an example where it won't work. I am not sure I understand what you are saying. I was going by the examples that Pedro wrote
Thanks
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
It's the calculation that is the problem. Pedro want's to be able to perform a calculation that is stored in a string which presumably is read from elsewhere. i.e.

B4X:
Dim CalcStr as String = "(234/403)-20*50"
Dim s As Double = $"${NumberFormat(CalcStr, 1,4)}"$

Which will fail.
 
Upvote 0
Top