当从列表框中选择 "Not complete" 时,我希望将 0 输入到文本框中

when "Not complete" is selected from a listbox i want 0 to be entered into a textbox

我有一个列表框,其中包含一个名为 "Not complete" 的项目,我希望在选择此项时将 0 输入到文本框中,这可能吗?

    If CoreUnit1ComboBx.SelectedItem = Nothing Or CoreUnit1CSComBx.SelectedItem = Nothing Or CoreUnit1TxtBx.Text = "" Then
    ElseIf CoreUnit1CSComBx.SelectedItem = "Not Complete" Then
        CoreUnit1Total = 0
        CoreUnit1TxtBx.Text = "0" 

    Else
        CoreUnit1Total = CoreUnit1CSComBx.SelectedItem * CoreUnit1TxtBx.Text
    End If

有很多方法可以做到这一点,但是 case statement 可能是最好的,而且从长远来看 运行 比使用 if statement.

更干净
Public Class Form1
Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
    Select Case ComboBox1.SelectedItem
        Case Is = "Not Completed"
            TextBox1.Text = "0"
    End Select
End Sub

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    ComboBox1.Items.Add("Not Completed")
End Sub
End Class

如果您有任何问题,请告诉我,如上所述,实现您想要完成的目标的方法不止一种。
快乐编码!