Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hey people, I've made a Class called XlCell, and basically it has all the properties (that I will need) for a cell in Excel, so I can quickly build a 'virtual' Excel worksheet in .NET and export it to an Excel macro, which will do the rest. However.....

 

In order to do This I will need this code outside of the class to use it:

 

Dim Cells() As New XlCell()

 

Problem is, it doesn't like this line, saying "Arrays cannot be declared with 'New'." on the error tooltip. I can create the object as a singular, but it hates arrays. How can I do this?

 

Ps: it's going to be a 2 dimensional array (Rows/Columns), just in case it makes any difference to the response.

Chaos is merely logic beyond human comprehension
  • *Experts*
Posted

You don't instantinate an array but rather its contents. You can do something like this:

cells(1) = New XlCell()

After you declare your array.

Posted
You don't instantinate an array but rather its contents. You can do something like this:

cells(1) = New XlCell()

After you declare your array.

 

Sweet! So smething along the lines of this is fine:

 

Dim Num as integer
Dim Num2 as integer

Redim Cells(10,20)

For Num = 1 to 10
For Num2 = 1 to 20
Cells(Num, Num2) = New XlCell()
Next
Next

 

And also, how would I Dim the Cells() to start?

 

Cheers dude

Chaos is merely logic beyond human comprehension
Posted
K, cheers guys, I'm gonna try the code when I get back. A lovely 11 hours of college today, hooray for me..
Chaos is merely logic beyond human comprehension

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...