Setting default values of user defined data type

  • Thread starter Thread starter Adrian
  • Start date Start date
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
 
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
 
Back
Top