What is visual display?

What is the correct code for selecting an item from the combobox to display in textbox for Visual Studio 2005?

  • I know it is a "Select case" code. I want to select something in a combobox and the information would show up in the textbox. I used it in VB6 I can not get it to work in Visual Studio 2005. Is this code below correct because it does not work: Select Case DirectCast(sender, ComboBox).Name Case "Paul" TextBox4.Text = ("Paul Selected") Case "John" TextBox4.Text = ("John Selected") Case "Luke" TextBox4.Text = ("Luke Selected") End Select

  • Answer:

    This will work, Select Case DirectCast(sender, _ comboBox).SelectedItem.ToString notice that ".SelectedItem.ToString" has been added to the the code that you have written will return the name assigned to the combox control: i.e. ComboBox1 the code above will return the value of what you have selected. I'd change youre code to do this as well: text4.text = "" ' clear the previous text dim cb as string cb = DirectCast(sender, ComboBox).SelectedItem.ToString TextBox4.Text = cb & " Selected" this will add the value of whatever you select to the textbox. Since the value entered only differs by name you dont need to use a select case statement Hope this helps

Johnny T at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

I take it this code is in the TextChanged event of the combo box you are using? Does DirectCase take 2 parameters? Only thing I can think of was to use the 'as' keyword somewhere, but that's the C# in me talking. For example: Select Case DirectCast(sender as CombBox).Name

Storm Sams

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.