-3
これをコード化しました。それは問題ありませんが、少ないコードで書くことができますか?少ないコードでListBoxに10個の数字を追加するには?
If D = 10 Then
ListBox3.Items.Add(1)
ListBox3.Items.Add(2)
ListBox3.Items.Add(3)
ListBox3.Items.Add(4)
ListBox3.Items.Add(5)
ListBox3.Items.Add(6)
ListBox3.Items.Add(7)
ListBox3.Items.Add(8)
ListBox3.Items.Add(9)
ListBox3.Items.Add(10)
End If
あなたは私の質問を理解していない場合は、次の例読むことができます:
を我々は
Dim A As Integer
Dim B As Integer
Dim C As Integer
Dim D As Integer
をコーディングすることができますが、我々はこの
ような、より簡潔な方法でそれをコーディングすることができますDim A, B, C, D As Integer
ListBox3.Items.AddRange(Enumerable.Range(1,10).Cast(Of Object).ToArray)) ' – Plutonix
参照:[ループ構造(Visual Basic)](https://msdn.microsoft。 com/en-us/library/ezk76t25.aspx?f = 255&MSPPError = -2147217396)と[stackoverflowドキュメント "For ... Next"](http://stackoverflow.com/documentation/vb.net/1639/looping/ 5296/for-next#t = 201608061516422319054) –