A var-len string is a pseudo-object which has its own (hidden) default constructor.
So an UDT containing such a string also has its own (hidden) default constructor.
Referring to the 'Type (Temporary)' documentation page, when an UDT has any constructor,
'Type(parameters)' is allowed only if a constructor matching with
'parameters' also exists.
Other examples very simple:
Code: Select all
Type UDT
Dim As Integer I '' no constructor
End Type
Dim As UDT u = Type(123) '' works
Code: Select all
Type UDT
Dim As Integer I = 1 '' initialyser with constant value => (hidden) default constructor
End Type
Dim As UDT u = Type(123) '' does not work
Dim As UDT u1 = Type() '' works (a constructor matches)
Code: Select all
Type UDT
Dim As Integer I = 1 '' initialyser with constant value => (hidden) default constructor
Declare Constructor (Byval As Integer)
End Type
Constructor UDT (Byval i0 As Integer) '' explicit constructor (with one integer parameter)
This.I = i0
End Constructor
Dim As UDT u = Type(123) '' works now (the explicit constructor matches)
Dim As UDT u1 = Type() '' no longer works (explicit constructor(s) cancel(s) all implicit constructor(s))