Hi Jose Roca,
Dim sample As CWSTR = "My Sample String"
Print sample
This will print "My Sample String" on screen. I know that cwstr is a udt. What is the magic behind this ? I mean when i try to write a udt like this
Type MyType
m_String As String
Declare Constructor(Byval sParam As String)
End Type
Constructor MyType(Byval sParam As String)
m_String = sParam
End Constructor
Dim sample As MyType = "enter man"
Print sample
It result in an "Invalid data type " error. I know that i am missing so many things in my constructor. I have posted this code only for expressing my idea because, i knew that i cant really express this idea through words. English is not my first language. Thats why the subject title look weird. Could you please explain me how to do this ?
Hi,
I am i missing this ?
Declare Operator Print(Byval udtName as MyType)
And ...
Operator MyType.Print(Byval udtName as MyType)
Print udtName. m_String
End Operator
The "magic" is casting.
Type MyType
m_String As String
Declare Constructor(Byval sParam As String)
DECLARE OPERATOR CAST () BYREF AS STRING
End Type
Constructor MyType(Byval sParam As String)
m_String = sParam
End Constructor
OPERATOR MyType.CAST () BYREF AS STRING
OPERATOR = m_String
END OPERATOR
Dim sample As MyType = "enter man"
Print sample
@Jose,
Wow!, Thanks a lot.