Hi Michael,
Maybe you can use PropertyBag. Try this:
- Create your UDT
Type YourUDT
Name as string * 20
BirthDate as Date
CreditLimit as Currency
End Type
- Declare a variable:
Dim mYourUDT as YourUDT
- Display length for variable of type YourUDT
MsgBox Len(mYourUDT)
- Now that you know how big a YourUDT variable is, you can declare simpler
UDT that will be big enough to hold a YourUDT variable's data:
Type YourUDTHold
HoldData As String * 36
End Type
- As an example, the following code uses the YourUDTHold and YourUDT data
Types I previously defined. This code sets the values of the YourUDT
variable elements and then uses the LSet command to move the data into a
YourUDTHold type variable:
Dim mData as YourUDT
DIM mStore as YourUDTHold
mData.Name = "Juliano"
mData.BDate = "15/10/74"
nData.CreditLimit = -100
LSet mStore = mData
- This string element (mStore.HoldData) can be used anywhere a string
variable can be used.
I get it from "Visual Basic Object & Component Handbook". by Peter Vogel.
Good Lucky and sorry for my english.
Juliano Moraes Rodrigues
-----Mensagem original-----
De: Michael Findlay [mailto:michaelgfindlay@h...]
Enviada em: quarta-feira, 22 de agosto de 2001 5:40
Para: professional vb
Assunto: [pro_vb] RE: Storing user-defined types in a Data Structure
Thanks very much for this Nigel. I still face a problem though. I want
to keep a store of several instances of the data structure (OriginalUDT in
your example).
I'd need to add these data structures (as you've described) into a 'store'
of some sorts and then would still require to be able to search on each
value of 'strString' to decide which instance I want to return (strString
is basically a key value). I initially planned to store this type of data
structure in a PropertyBag but it doesn't support the storage of arrays so
I'm still looking for a solution.
> for example
>
> Private Type udtArrayStructure
> myString as String
> myInt as Integer
> End Type
>
> Private Type OriginalUDT
> strString as string
> intValue As Integer
> udtArray() as udtArrayStructure 'create an array of the above type
> End Type
>
> Private m_DataStructure as OriginalUDT