1

好吧 2 个组合框,如果您选择其中一个或下拉列表并选择说 50,我希望另一个 cbo 依赖于该选择并自动填写剩余的 (50)。

这是我的代码

Public Class 
Dim minus() As integer = {100D}
Dim answers(3) As Integer
Dim cbo() As ComboBox

Form Load;
cbo = New ComboBox() {cbopercentmain, cbopercentpro}

Private Sub cbompercentmain_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbopercentmain.SelectedIndexChanged
        Dim cbo As ComboBox = DirectCast(sender, ComboBox)
        If cbo.SelectedIndex = -1 Then
            answers(Array.IndexOf(comboboxes, cbo)) = 0
        Else
            answers(Array.IndexOf(comboboxes, cbo)) = CInt(cbo.Text) - minus(Array.IndexOf(comboboxes, cbo))
        End If
        cbopercentpro.Text = answers.Sum.ToString
    End Sub

任何帮助将不胜感激!

4

0 回答 0