Home All Groups Group Topic Archive Search About
Author
5 May 2006 2:26 AM
eBob.com
I've done a lot of programming but very little OOP.  Would someone be kind
enough to explain to me why I get a "declaration expected" on this
statement: anythingarray(0) = new anything(3)

Thanks,  Bob

Public Class Form1

Inherits System.Windows.Forms.Form

Dim anythingarray(4) As anything

anythingarray(0) = new anything(3)    ' < < here's the statement in error

#Region " Windows Form Designer generated code "



#End Region

End Class

Public Class anything

Dim onenum As Integer

Sub New(ByVal x As Integer)

onenum = x

End Sub

End Class

Author
5 May 2006 5:03 AM
Cor Ligthert [MVP]
eBob,

What you want to do with those statements, even if it was not this error
that the statements are not correct.

If it is a try for a redim, than avoid the array, use the arraylist.


Cor
Author
5 May 2006 2:19 PM
Claes Bergefall
The conflicting statement needs to be inside a method

    /claes

Show quoteHide quote
"eBob.com" <eBob.***@totallybogus.com> wrote in message
news:%23kVlKt%23bGHA.3352@TK2MSFTNGP03.phx.gbl...
> I've done a lot of programming but very little OOP.  Would someone be kind
> enough to explain to me why I get a "declaration expected" on this
> statement: anythingarray(0) = new anything(3)
>
> Thanks,  Bob
>
> Public Class Form1
>
> Inherits System.Windows.Forms.Form
>
> Dim anythingarray(4) As anything
>
> anythingarray(0) = new anything(3)    ' < < here's the statement in error
>
> #Region " Windows Form Designer generated code "
>
>
>
> #End Region
>
> End Class
>
> Public Class anything
>
> Dim onenum As Integer
>
> Sub New(ByVal x As Integer)
>
> onenum = x
>
> End Sub
>
> End Class
>
>