-2
if (fromListBox.SelectedIndex = 0 && toListBox.SelectedIndex = 1)
    input /= 12;
else if (fromListBox.SelectedIndex = 0 && toListBox.SelectedIndex = 2)
    input /= 36;
else if (fromListBox.SelectedIndex = 1 && toListBox.SelectedIndex = 0)
    input *= 12;
else if (fromListBox.SelectedIndex = 1 && toListBox.SelectedIndex = 2)
    input /= 3;
else if (fromListBox.SelectedIndex = 2 && toListBox.SelectedIndex = 0)
    input *= 36;
else if (fromListBox.SelectedIndex = 2 && toListBox.SelectedIndex = 1)
    input *= 3;

What am I doing wrong? How do I pull data from different listboxes for calculation?

This is a distance conversion application; user inputs a number into the startingDistanceTextBox, chooses what the measurement it is from the fromListBox and what they wish to convert it to from the toListBox; items are: inches, feet & yards(both listboxes). I am to display the conversion in a label.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • What is `input`? What is the error? What is different from what you expect? – Bojan Komazec Feb 09 '14 at 21:17
  • 1
    _"What am I doing wrong?"_ - you don't show what compiler error you get. Anyway, you want to compare (`==`), not assign (`=`). – CodeCaster Feb 09 '14 at 21:17
  • Duplicate of [Help converting type - cannot implicitly convert type 'string' to 'bool'](http://stackoverflow.com/questions/871530/help-converting-type-cannot-implicitly-convert-type-string-to-bool). – CodeCaster Feb 09 '14 at 21:20
  • Error 1 Operator '&&' cannot be applied to operands of type 'int' and 'int'. – user3290655 Feb 09 '14 at 21:22
  • 1
    -1 you failed to state in the question what was wrong with the code. If you ask about a compiler error you must give that error. The fact that you did not tells me that you don't read compiler errors at all. That's a bad habit that you must get past. – David Heffernan Feb 09 '14 at 21:28
  • I'm new here; first day, first question. – user3290655 Feb 09 '14 at 22:03

1 Answers1

0

You are using assignment operator =, you should use == to compare your values

fromListBox.SelectedIndex == 0
Selman Genç
  • 100,147
  • 13
  • 119
  • 184
  • If the solution worked, you should accept the answer. There should be a check mark underneath the answer score that you can click. http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work – Dmitriy Khaykin Feb 09 '14 at 22:16