Reputation: 23042
The following trivial example doesn't work:
Public Type MyType
a As Double
b As Integer
End Type
Function Test() As Variant
Dim x As MyType
Test = 2
End Function
Compile Error: User-defined type not defined
How do I "define" the type?
Upvotes: 1
Views: 68
Reputation: 29421
your code compiles fine in my excel 2010
anyhow it'd be of no use for exploiting a user defined type
here follows a "complete" example
Option Explicit
Public Type MyType
a As Double
b As Integer
End Type
Sub main()
Dim x As MyType
'initialize fields of your type
x.a = 1.2
x.b = 1
MsgBox Test(x)
End Sub
Function Test(x As MyType) As Variant
Test = x.a + x.b
End Function
Upvotes: 1