Declaration Expected

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
 
T

tomb

Try putting the statement in the Sub New(), or some other function or
procedure. It looks like it's in the declarations portion.

Tom
 
C

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top