0

Hey I am trying to convert string text boxes so i can multiply two variables and the display it in a third text box. My text boxes are txtTotalPre and i am trying to multiply this number by 1 and then display it in txtTotal.

   String number = txtSub.getText();
   String.valueOf(number);
   int price = 1;
   txtTotal.setText(number * price);
user2165264
  • 9
  • 1
  • 1
  • 2
  • 2
    Duplicate: http://stackoverflow.com/questions/5585779/how-to-convert-string-to-int-in-java – David Mar 13 '13 at 11:59
  • 1
    Welcome to Stackoverflow, Please make it a habit to search before posting! It is more than likely someone else had the same problems too – Ahmed Aeon Axan Mar 13 '13 at 12:15

1 Answers1

1

try

int number = Integer.parseInt(txtSub.getText());

instead of

String number = txtSub.getText();
String.valueOf(number);
Boann
  • 48,794
  • 16
  • 117
  • 146
rbobin
  • 39
  • 5