2

我有一个ProgressBar名为ProgressBar1. 我需要它来显示For Each循环的进度。它逐步完成,但最后我得到了这个错误“ Additional information: Value of '102' is not valid for 'Value'. 'Value' should be between 'minimum' and 'maximum'.”无论我做什么,我都无法让决赛ProgressBar1.ValueProgressBar1.Value.

这是我到目前为止的代码:

Public Shared tickerArray() As String = {"GOOG", "V", "AAPL", "BBBY", "AMZN", "DISCA"}

ProgressBar1.Maximum = (100 / tickerArray.Length) * tickerArray.Length
ProgressBar1.Show()

For Each tickerValue In tickerArray
    Historical_Stock_Prices.addBulk_Historical_Stock_Prices(tickerValue, tblName)
    ProgressBar1.Value += (100 / tickerArray.Length)
Next tickerValue
4

1 回答 1

4

为什么不将最大值设置为数组的长度?

ProgressBar1.Maximum = tickerArray.Length

现在在循环中,您可以将当前值增加 1

ProgressBar1.Value += 1
于 2013-10-08T20:15:54.787 回答