我需要一点帮助。除了一件小事之外,我的代码 99% 都可以正常工作。
我正在制作所谓的“自助餐厅调查”,它记录来自用户自己输入的组合框的响应。
这里的问题是它计算(放置 *)数字 1 比我在 ComboBox 中选择的数字少。
如果我在它的末尾添加 + 1,SelectedIndex
则将 * 放置在正确的数字上,但对于 #10 响应(ratingComboBox.SelectedIndex)+= 1 它不会这样做
任何帮助都会很棒。提前致谢。
这是我的代码:
Public Class CafeteriaSurveyForm
Dim choices As Integer() = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
Dim responses(0 To 11) As Integer
Dim responseCounter As Integer = 0
' displays histogram
Sub DisplayHistogram()
outputTextBox.Text = ("Rating" & vbTab & "Frequency")
For i As Integer = 0 To choices.GetUpperBound(0)
For ii As Integer = 1 To responses(i)
outputTextBox.Text &= ("*")
Next
outputTextBox.Text &= (vbNewLine & choices(i) & vbTab)
Next
End Sub ' DisplayHistogram
Private Sub CafeteriaSurveyForm_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
ratingComboBox.DataSource = choices
End Sub
Private Sub submitButton_Click(sender As System.Object, e As System.EventArgs) Handles submitButton.Click
responseCounter += 1
responses(ratingComboBox.SelectedIndex) += 1
DisplayHistogram()
End Sub
End Class ' CafeteriaSurveyForm