About 'collection' of vba

T

topalps

Following is some some segment of vba in excel in one module

public type tradeVO
trade_date as date
value_date as date
deal_number as string
ccy_bought as string
ccy_sold as string
end type

public sub try()
dim trades as new collection
dim t as new tradeVO

trades.add t
end sub

------------------------------
there is a compile error: "only user-defined types defined in public
object modules can be coerced to or from a variant or passed to
late-bound functions"

what's it about? i can't get it
 
C

Cindy M.

Following is some some segment of vba in excel in one moduleI believe you can only use a Collection to hold "objects" (instances
of a class). I think you need to use an array to hold a group of
types.
Public type tradeVO
trade_date as date
value_date as date
deal_number as string
ccy_bought as string
ccy_sold as string
end type

public sub try()
dim trades as new collection
dim t as new tradeVO

trades.add t
end sub

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :)
 
T

topalps

got it


Cindy M. 写é“:
I believe you can only use a Collection to hold "objects" (instances
of a class). I think you need to use an array to hold a group of
types.


Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)


This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :)
 

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