ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   class modules and array (https://www.excelbanter.com/excel-programming/330975-class-modules-array.html)

Martin Bauer

class modules and array
 
hi,

here is my problem - I would like to combine a class modules and an array
???

here is my code example

class module stock

public datum as date
public close as double

my module

dim xx as new stock

for =1 to 20
xx(i).date="21/02/2005"
xx(i).close="102"
next i

Where is my error ???

TIA
Best Regards
Ciao
Martin

Harald Staff

class modules and array
 
Error as in a single error ? Sorry my friend:

"close" is a reserved VB word. change to something else.
dim xx as new stock is not an array. change to
dim xx(1 to 20) as new stock
i is not declared: Dim i As Long.
for =1 to 20 is nonsense. Change to
for i =1 to 20
xx(i).date="21/02/2005"
stock does not have a date property. stock has a datum property.
"21/02/2005" is not a date, it's a String.
"102" is not Double, it's a String.

HTH. Best wishes Harald

Martin Bauer" skrev i melding
0...
hi,

here is my problem - I would like to combine a class modules and an array
???

here is my code example

class module stock

public datum as date
public close as double

my module

dim xx as new stock

for =1 to 20
xx(i).date="21/02/2005"
xx(i).close="102"
next i

Where is my error ???

TIA
Best Regards
Ciao
Martin




Tushar Mehta

class modules and array
 
Where are you declaring the array of type stock?

The same rules that apply to defining an array of a basic data type
apply to a constructed data type.

Remember that an array of type Integer would be declared as
Dim X(0 to 10) as Integer

So, an array of type Stock would be declared as...

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article ,
says...
hi,

here is my problem - I would like to combine a class modules and an array
???

here is my code example

class module stock

public datum as date
public close as double

my module

dim xx as new stock

for =1 to 20
xx(i).date="21/02/2005"
xx(i).close="102"
next i

Where is my error ???

TIA
Best Regards
Ciao
Martin



All times are GMT +1. The time now is 01:28 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com