Can't use Math operators with variables I saved in Textfields
so i have this code where i want users to input and item name along with some numbers for each item(which i would like to preform some math operations on) I'm using Record store
working using WTK22
//UI Text Fields
TextField searchField = new TextField ("Search By Item Name", "", 25, TextField.ANY);
TextField userId = new TextField ("Item ID", "", 25, TextField.ANY);
TextField customerId = new TextField ("Item", "", 25, TextField.ANY);
TextField productName = new TextField ("CTM", "", 25,TextField.NUMERIC);
TextField productName2 = new TextField ("CTR", "", 25,TextField.NUMERIC);
TextField productName3 = new TextField ("CTC", "", 25,TextField.NUMERIC);
TextField orderQty = new TextField ("Quantity", "", 5,TextField.NUMERIC);
and later on I want to
orderIdForm.append( productName2 - productName);
and it tells me i can do that with textfield:frusty:.. so i tried
orderIdForm.append(Float.parse(productName2) - Float.parse(productName)) ;
still no luck... please help and thank you for your time
Re: Can't use Math operators with variables I saved in Textfields
Re: Can't use Math operators with variables I saved in Textfields
What are you trying to achieve?
If it's subtracting the integer representation of those Strings then you need to do the parsing, though I would use Integer.parse().
If that doesn't work then you have to give us the full exception, including the stack trace, showing where in your code the exception is thrown.