Ron,
As Herfried suggests I normally use the first syntax, however you need the
second syntax when you want an array, but you don't want or need the
variable.
For example:
Sub Test(labels() As Label)
End Sub
Test(New Label(){Me.lbl1, Me.lbl2, Me.lbl3})
Here I want to send an array of Labels to the Test method, however I don't
want or need an array variable to hold them.
Hope this helps
Jay
"Ron" <(E-Mail Removed)> wrote in message
news:639701c4c8d9$9cfe81c0$(E-Mail Removed)...
> Hello,
>
> I created an array of label controls like this:
>
> Dim lbl() As Label = {Me.lbl1, Me.lbl2, Me.lbl3}
>
> and was able to iterate through the array. But then I saw
> another way to declare the same array:
>
> Dim lbl() As Label = New Label(){Me.lbl1, Me.lbl2, Me.lbl3}
>
> Both ways seems to work fine, but I want to get in the
> practice of doing this correctly. Is there a difference
> between using New or not for this? If so, what is the
> difference?
>
> Thanks,
> Ron
|