CryoEnix Posted October 10, 2004 Posted October 10, 2004 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. Quote Chaos is merely logic beyond human comprehension
*Experts* mutant Posted October 10, 2004 *Experts* Posted October 10, 2004 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. Quote
CryoEnix Posted October 10, 2004 Author Posted October 10, 2004 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 Quote Chaos is merely logic beyond human comprehension
BlackStone Posted October 10, 2004 Posted October 10, 2004 Dim Cells() As Cell Quote "For every complex problem, there is a solution that is simple, neat, and wrong." - H. L. Mencken
CryoEnix Posted October 11, 2004 Author Posted October 11, 2004 K, cheers guys, I'm gonna try the code when I get back. A lovely 11 hours of college today, hooray for me.. Quote Chaos is merely logic beyond human comprehension
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.