Advertisement
TermSpar

Dynamic Array

Feb 10th, 2016
1,989
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 0.51 KB | None | 0 0
  1. Public Class Form1
  2.     Dim newArray() As Integer
  3.     Dim rndNum As New Random
  4.     Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
  5.         lstItems.Items.Clear()
  6.         ReDim newArray(Val(txtArray.Text) - 1)
  7.         addTo()
  8.     End Sub
  9.  
  10.     Sub addTo()
  11.         For i = 0 To newArray.Length - 1
  12.             newArray(i) = rndNum.Next(1, 10)
  13.         Next
  14.         Array.ForEach(newArray, New Action(Of Integer)(Sub(x) lstItems.Items.Add(x)))
  15.     End Sub
  16. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement