Re: Setting default values of user defined data type

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Peter Beach (pbeach_at_globe.net.nz)
Date: 07/13/04


Date: Tue, 13 Jul 2004 16:48:41 +1200

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

"Adrian" <xinke@hotmail.com> wrote in message
news:OSlLFvIaEHA.212@TK2MSFTNGP12.phx.gbl...
> 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
>
>



Relevant Pages

  • Re: Magic Instantiation! Most Annoying! :-(
    ... I have a Project class that contains a User property amongst lots of other ... In the Project class's constructor I initialise all the class's parameter ... Projects constructor, the User property has also been initialised, when it ... Kindest Regards ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Magic Instantiation! Most Annoying! :-(
    ... I have a Project class that contains a User property amongst lots of other ... In the Project class's constructor I initialise all the class's parameter ... Projects constructor, the User property has also been initialised, when it ... Kindest Regards ...
    (microsoft.public.dotnet.framework)
  • Re: Magic Instantiation! Most Annoying! :-(
    ... I have a Project class that contains a User property amongst lots of other ... In the Project class's constructor I initialise all the class's parameter ... Projects constructor, the User property has also been initialised, when it ... Kindest Regards ...
    (microsoft.public.dotnet.general)
  • RE: Sharing variables across Forms
    ... Regards, ... > acess it if I initialise it in a different form than the one that is ... > Posted Via Usenet.com Premium Usenet Newsgroup Services ...
    (microsoft.public.dotnet.languages.csharp)
  • AV when calling setlength on a dynamic array of boolean
    ... In an object I use a dynamic array of booleans to store some hardware ... When I initialise the object it reads from a database and calculates ... crashes with an access violation even though DBSize is unchanged. ...
    (comp.lang.pascal.delphi.misc)