#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    1
    Rep Power
    0

    Question 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

    //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.. so i tried
    orderIdForm.append(Float.parse(productName2) -
    Float.parse(productName)) ;
    still no luck... please help and thank you for your time
    Last edited by IvanNYC; December 3rd, 2012 at 11:50 PM. Reason: error in title
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2011
    Location
    Madgaon, Goa, India
    Posts
    6
    Rep Power
    0
    Cross posted on java-forums.org at New To Java -> Can't use Math operators with variables I saved in Textfields

    db
  4. #3
  5. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,713
    Rep Power
    348
    Do the math in a separate statement that assigns a value to a numeric variable
    then set the textfield from the results of that statement.

IMN logo majestic logo threadwatch logo seochat tools logo