我要根据第一个进度条划分4个进度条,将所有组合值赋予100。如果是第一个进度条,则随机值将从(45,100)开始,如果值为45,那么其他进度条值Random将是progressbar2 = 15,progressbar = 3 15或progressbar 25,依此类推。 (这是一个例子)。剩余三个进度条的随机值+加到第一个值,必须为100。
如果Progressbar1 = 75,则其他3个Progressbar值的总和=25。75 + 25 = 100。 例如:progressbar2 = 10,progressbar3 = 10和progressbar4 = 5。
If LBPublic.Text = ("1") Then
If AnswerA.Location = New Point(LocationA) Then
Dim R As New Random
Dim value As Integer
value = R.Next(45, 100)
ProgressBar1.Value += value
LbProcentA.Text = ProgressBar1.Value
Dim R1 As New Random
Dim value1 As Integer
value1 = R.Next(0, value)
ProgressBar2.Value += value1
LbProcentB.Text = ProgressBar2.Value
End If
End If
我并没有真正做到这一点。我注意到带有(progressbar1,progressbar2,progressbar3和progressbar4的进度条。
答案 0 :(得分:0)
尝试这样的事情:
Private R As New Random
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
ProgressBar1.Value = R.Next(45, 101) ' min of 45, max of 100
ProgressBar2.Value = R.Next(101 - ProgressBar1.Value)
ProgressBar3.Value = R.Next(101 - (ProgressBar1.Value + ProgressBar2.Value))
ProgressBar4.Value = 100 - (ProgressBar1.Value + ProgressBar2.Value + ProgressBar3.Value)
Debug.Print("ProgressBar1: " & ProgressBar1.Value)
Debug.Print("ProgressBar2: " & ProgressBar2.Value)
Debug.Print("ProgressBar3: " & ProgressBar3.Value)
Debug.Print("ProgressBar4: " & ProgressBar4.Value)
Debug.Print("Total: " & (ProgressBar1.Value + ProgressBar2.Value + ProgressBar3.Value + ProgressBar4.Value))
End Sub