It used to work. Now it doesn't. I can't see why, as the code hasn't been changed.
[tt]
Public Function RandomFile()
Dim Rand As Integer
Randomize
Rand = Int(((FileList.ListCount) * Rnd) + 0)
FileList.ListIndex = Rand
Address = DirList.Path & "\" & FileList.FileName
End Function[/tt]
When the Random button is clicked, it should run that function, which it does... then carry on from there. A random integer is selected between 0 and FileList.ListCount. Then the ListIndex of the filelistbox(FileList) is set to the random number. Address is an address bar.
I get the error:
Run time error 381
Invalid property array index
... on FileList.ListIndex = Rand. It's saying that FileList.ListIndex = 0, and that Rand = whatever random number it generated. But nothing happens.
[tt]
Public Function RandomFile()
Dim Rand As Integer
Randomize
Rand = Int(((FileList.ListCount) * Rnd) + 0)
FileList.ListIndex = Rand
Address = DirList.Path & "\" & FileList.FileName
End Function[/tt]
When the Random button is clicked, it should run that function, which it does... then carry on from there. A random integer is selected between 0 and FileList.ListCount. Then the ListIndex of the filelistbox(FileList) is set to the random number. Address is an address bar.
I get the error:
Run time error 381
Invalid property array index
... on FileList.ListIndex = Rand. It's saying that FileList.ListIndex = 0, and that Rand = whatever random number it generated. But nothing happens.