Basic Macro UserDef Types, get Actual DataTypes and Names within defined UserType

Hello,

Hoping somebody can help me please!!!

I think I know the answer could well be no as I have been searching around and trying different things like Collections, Enum Maps etc but still haven’t found a solution apart from generating the physical script at runtime and placing it in a module.

Scenario…

I create a user def type ie

Type myType
oSomeObject As Object
sSomeFName As String
sSomeLName As String
nSomeNumber As Integer
End Type

Dim tType as New myType

now I know if I want to assign a value to say sSomeFName then I would do something like this…
tType.sSomeFName = “Pet”

And if I want the value of that var at a later stage I would do something like this
Dim sVar
sVar = tType.sSomeFName

and so on etc etc

but is it possible to access the actual datatypes and names in the userdef type ie something like
Dim t
Dim nCount
Dim oSomeType()
Dim oSomeTypeName()
nCount = tType.numOfDataTypes …cannot find any such function apart from UBound for Arrays which wont work.

ReDim oSomeType(nCount)
ReDim oSomeTypeName(nCount)

For Each t in tType
oSomeTypeName(nCount) = getDataTypeName(t) …so on 1st loop this would be ‘oSomeObject’ and on the 2nd this would be ‘sSomeFName’

oSomeType(nCount) = getDataType(t) … and again on the 1st loop this would be ‘Object’ and on the 2nd this would be ‘String’ …and so on
Next t

I can get the Type from say “tType” via TypeName and VarType etc but that only brings up the initial type as an object not the parts that make it up.

I know it will be said, “well if you are using a user def type you should know what it is made up of” :smiley: , which is right and true but I have found myself wanting to get the physical make up of some types like the above without having to back track in coding all the time.

Is this possible or is there perhaps another way to achieve this?? :thinking:

Many thanks
P.R

Latest Basic Voodoo on forum.openoffice.org

Hi Villeroy,

Thanks for the quick reply and the link.

I will look into these examples and report back. :smiley:

Many thanks
P.R