Arrays wont work?

ok so like in vb 6 this would be an example of a simple array of form1 which would work for what i want to do.

Now if you upgrade to vb.net it says you cannot have an array.
The following wont work :( and if i take out the new it gives me errors i dont get when i do the loop.

How can i make this work

Dim pm(100) As New Form1

Private Sub Command1_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command1.Click
Dim a As Integer
For a = 1 To 100
If pm(a).Tag = "" Then
MsgBox("found")
Exit Sub
End If
Next a
End Sub
End Class



Answer this question

Arrays wont work?

  • KenH++

    still it wont work


  • Mohankumarj

    you want an array of 100 form objects

  • Gerben3000

    hi,

    i just wonder why do you have an array of 100 forms

    best regards



  • cool_shezz

    oops. . . hit enter by accident. . .

    and tag is an object. . .

    if prn(a).Tag is nothing

    [god, I hate the vb 'Is' for object reference comparison. . . almost as much as I hate the word 'nothing' for null. . . yeah, right. . . vb reads easier. . .sure it does]



  • marieMyers

    oops. . . copied bad code -

    For a as Integer = 0 to a.Length -1
    If pm(a).Tag is Nothing Then
    MsgBox("found")
    Exit Sub
    End If
    Next

    For each frm as Form in prn
    If frm.Tag is nothing Then
    MsgBox("found")
    Exit Sub
    End If
    Next



  • Patrick Carnahan - MSFT

    oops. .. arrays are zero based now (the way they should have been by default in vbsux)

    For a as Integer = 0 to a.Length -1
    If pm(a).Tag = "" Then
    MsgBox("found")
    Exit Sub
    End If
    Next



  • Arrays wont work?