I cant seem to see what is wrong with this arrary size. It works if i set the random number to 10
pretty sure it's to do with this line For i = 0 To intResult but i cant for the life of me figure it out.
pretty sure it's to do with this line For i = 0 To intResult but i cant for the life of me figure it out.
VB.NET:
Dim intResult As Integer
'// Initializes the random-number generator, otherwise each time you run your
'// program, the sequence of numbers will be the same
Randomize()
intResult = Int((100 * Rnd()) + 1) '// Generate random value between 1 and 100.
'//Add the new random list of directorys to listbox
Dim sDirs() As String
Dim i As Integer = 1
sDirs = System.IO.Directory.GetDirectories("c:\")
For i = 0 To intResult
lstDirectorys.Items.Add(sDirs(i))
Next
'//Set the last directory as a varible
Dim strLastDir As String = ""
strLastDir = sDirs(lstDirectorys.Items.Count - 1)