Setting default values of user defined data type

A

Adrian

Hi,

Can we set the default values of user-defined data types ? Thanks.

The following code doesn't work ...
" Type ABC

var1 as string * 30 = "Test"

End Type
"

regards,
Adrian
 
P

Peter Beach

Hi Adrian,

Sadly you can't :-( On the bright-side, posting something like "you can't"
often produces a flood of postings saying "Oh, yes, you can", but I think in
this case I'm moderately safe.

VB/VBA will initialise all strings to empty, all numeric values to zero and
all booleans to False. So you could add a boolean item to your UDT called
(say) Initialised and then if it is False you could call an explicit
initialisation routine. I think that that is the best you can do I'm
afraid.

Regards,

Peter Beach
 

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