0
我想創建一個數組,其中12個數字輸入到文本框中,讀入數組中,並顯示在列表框中。我需要陣列停止在12個數字,而不是13,我似乎無法弄清楚如何做到這一點。任何幫助將不勝感激。這裏是我的代碼:Visual Basic 2012數組輸入到列表框1 offlink
Public Class Form1
Dim gasArray(11) As Decimal
Public Sub enterButton_Click(sender As Object, e As EventArgs) Handles enterButton.Click
gasArray(arrayListBox.Items.Count) = Convert.ToDecimal(enterPriceTextBox.Text)
displayLabel.Text = String.Empty ' clear Label
For i = 0 To gasArray.GetUpperBound(0) Step 1
If enterPriceTextBox.Text <> String.Empty Then
arrayListBox.Items.Add(enterPriceTextBox.Text)
enterPriceTextBox.Clear()
End If
Next
enterPriceTextBox.Focus()
highButton.Enabled = True
lowButton.Enabled = True
avgButton.Enabled = True
End Sub