Generate text from a combobox

0

I'm creating a program:

I'dliketoknowhowIcangenerateacodebyselectingoneoftheitemsinthecombobox.Forexample:Iselecttheitem"Issue resolved" in the textbox would appear "Issue marked as resolved".

Thank you in advance.

    
asked by anonymous 03.10.2015 / 23:26

2 answers

0

From what I understand you want to check when the selected in the Combo box exists in the options and create a message for it.

Private Sub ComboBox1_TextChanged(sender As Object, e As EventArgs) Handles ComboBox1.TextChanged
        If ComboBox1.Items.Contains(Trim(ComboBox1.Text)) Then
            'Ação ocorre se o texto da Combo box conter nos itens da Combo box
            Dim m As String = ""
            Select Case ComboBox1.Text
                Case "Questão resolvida" 'texto da Combo box
                    m = "Questão marcada como resolvida" 'mensagem se a questão for resolvida
                Case "Questão anulada"
                    m = "Questão marcada como anulada" 'mensagem se a questão for anulada
            End Select
            TextBox1.Text = m
        Else
            TextBox1.Text = ""
        End If
    End Sub

TextBox1.text is the text output.

ComboBox1 is the Combo Box.

    
04.10.2015 / 02:04
1
Private Sub Form_Load()
  Combo1.AddItem "Text1"
  Combo1.AddItem "Text2"
  Combo1.AddItem "Text3"
  Combo1.AddItem "Text4"
End Sub

Private Sub Combo1_Click() 'ListIndex inicia com 0 (zero) Dim strTeste As String Select Case Combo1.ListIndex Case 0 strTeste = "Text1" Case 1 strTeste = "Text2" Case 2 strTeste = "Text3" Case 3 strTeste = "Text4" End Select If Combo1.Text = strTeste Then MsgBox "OK!" End Sub
    
14.10.2015 / 17:52