基于百分比的2个组合框

时间:2013-09-10 15:16:07

标签: vb.net

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

任何帮助将不胜感激!

0 个答案:

没有答案