Declaration Expected

  • Thread starter Thread starter eBob.com
  • Start date Start date
E

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
 
Try putting the statement in the Sub New(), or some other function or
procedure. It looks like it's in the declarations portion.

Tom
 
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
 
Back
Top