I have some textfields that are part of a control set that I want to add up the data in them.
I have dragged data into them so now they have $ and commas in them.
XOJO does not inherently add them because it gets confused by the $ and , (comma)
Is there a good way to get around this to add them?
Thanks
The Locale is optional if the string has only numbers and decimal point (“1123.45”), the locale is required if the number has local formatting ("$1,123.45",“1.123,45€”).
It’ not just “required”
A Xojo app crashes without one
Thats really not helpful https://xojo.com/issue/63199
Sub Open()
Var locale As Locale = Locale.Current
Dim c1,c2, c3, c4, c5 As Currency
Try
c1 = Currency.FromString("123.45")
c2 = Currency.FromString("$123.45")
c3 = Currency.FromString("$123.45",locale)
Catch e As runtimeexception
Break
End Try
End Sub
Thanks for all the help - many different approaches to the same issue.
I stumbled across this and it worked. Yes you do have to use “locale”.
Var cellValue As String
Var locale As New Locale(“en-US”)
Var value As Currency
for ii = 0 to 6
if SecMoAmt(ii).text <> “” then
cellvalue = SecMoAmt(ii).text
value = Currency.FromString(cellValue,locale)
else
value = 0
end if
gpr = value + gpr
DepCareTotal.text = str(gpr)
next