さて、私は自分が間違っていることを理解するのに少し苦労しました。基本的に、平均よりも少ないListbox1アイテムを削除する必要がありますが、次のようになります。
System.ArgumentOutOfRangeExceptionが処理されませんでしたMessage=InvalidArgument='9'の値は'index'に対して無効です。パラメータ名:インデックス
Private Sub Label3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label3.Click
Dim Myrand As New Random
Dim res As Double
Dim i As Integer
Dim n As Integer
Dim tot As Double
Dim avarage As Double
ListBox1.Items.Clear()
For i = 0 To 14 Step 1
res = Math.Round(Myrand.NextDouble, 3)
ListBox1.Items.Add(res)
tot = tot + res
Next
avarage = tot / ListBox1.Items.Count
MsgBox(avarage)
For i = 0 To ListBox1.Items.Count - 1 Step 1
If ListBox1.Items(i) < avarage Then
ListBox1.Items.RemoveAt(i)
n = n + 1
End If
Next
MsgBox("Removed " & n & " items!")
End Sub
助言がありますか?