Jump to content

List box value

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
3 replies to this topic

#1
random guy

random guy

    Learning Programmer

  • Members
  • PipPipPip
  • 48 posts
i am using visual studio 2008. i have placed a listbox in a widget and have a collection of items in it (10^3,10^2,10^1,10^0). when the program is run i can select the proper values but i want my code to be able to detect the selected value, i tried

                

if (string.Compare(lengthUnits.Text, "10^3") == 1)

  {

                     

                    theLengthValue = theLengthValue * 1000;

  }


but that doesnt work. am i doing something wrong? thanks.
Hey like something i said? Helped you out? Or you just like supporting the Random Guy?
add to my rep. its quick and easy and definitely wont steal your girlfriend.

#2
Hignar

Hignar

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 420 posts
The string.Compare method returns a value of 0 if the strings are equal.

Also you might want to consider using a switch statement rather than a number of if statements to detect which option has been selected.

#3
random guy

random guy

    Learning Programmer

  • Members
  • PipPipPip
  • 48 posts
oh ya you're right. that was a silly mistake for me to have made. ya a switch statement would work better. thanks for the help.
Hey like something i said? Helped you out? Or you just like supporting the Random Guy?
add to my rep. its quick and easy and definitely wont steal your girlfriend.

#4
random guy

random guy

    Learning Programmer

  • Members
  • PipPipPip
  • 48 posts
thanks
Hey like something i said? Helped you out? Or you just like supporting the Random Guy?
add to my rep. its quick and easy and definitely wont steal your girlfriend.