2016-04-25 32 views
0

vb.net 2012其作品完美 但現在IAM試圖在VB6Visual Basic 6的組合框獲得selectedItem屬性值

Private Sub showSelectedButton_Click_1(sender As Object, e As EventArgs) Handles btn1.Click 
If ComboBox1.SelectedItem = "one" Then 
     MsgBox("ok") 
    ElseIf ComboBox1.SelectedItem = "tow" Then 
     MsgBox("no") 
    End If 
End Sub 

工作如何將selectedItem對VB6?

+0

IAM試圖讓在組合框中 我的意思是我想知道所選擇的項目是什麼項目被選中 –

回答

1

使用本:

If ComboBox1.List(ComboBox1.ListIndex) = "one" Then 

If ComboBox1.Text = "one" Then 
+0

完美工作,在此先感謝 –

1

請這個嘗試 -

Private Sub showSelectedButton_Click() 
    If ComboBox1.Text= "one" Then 
     MsgBox("ok") 
    ElseIf ComboBox1.Text= "tow" Then 
     MsgBox("no") 
    End If 
End Sub