really weird behavior in Vb.net 2010 Express. Here is the code:
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim a As Integer
'... Other lines...'
Dim di As New IO.DirectoryInfo(App_Path & "midi\")
Dim diar1 As IO.FileInfo() = di.GetFiles()
For a = 0 To diar1.Count
midrep(a) = diar1(a).Name
Next a
Preload()
End Sub
For some reason, the last line with “Preload()” instruction is not executed. (I checked with a breakpoint, it never even gets to it).
If I remove the cycle, it works fine. With the cycle, I get no errors or warnings, but the last line is completely ignored. The for cycle is properly executed.
I need the cycle before Preload().
Anyone knows how to solve the issue?
Thanks everyone
I’m going to hazard a guess that you’re not getting out of the
Forloop because you’re exceeding the bounds of eithermidrep(which you haven’t given us the type of) ordiar1, which is clearly an array ofFileInfoobjects.In fact, regardless of
midrep‘s definition, you’re definitely exceeding the bounds ofdiar1, asdiar1.Countis always going to be one higher than the last available index. You need to stop looping before you get todiar1.Count.