Clearing members of a UDT 
Author Message
 Clearing members of a UDT

What is the easiest way to clear each member of a UDT. Something like:

Public Type VB6_EXAMPLE
    sMember1 As String
    bMember2 As Boolean
    iMember3 As Integer
End Type

Dim ex As VB6_EXAMPLE

Set ex = Nothing

This doesn't work. Short of iterating through each member of the UDT, is
there an easy way to initialize the members to Empty?

BB



Mon, 12 Dec 2005 08:05:23 GMT  
 Clearing members of a UDT
You can keep an empty copy and set that to ex, or use a function that
returns an empty copy and set that to ex.

--
Michael Culley


Quote:
> What is the easiest way to clear each member of a UDT. Something like:

> Public Type VB6_EXAMPLE
>     sMember1 As String
>     bMember2 As Boolean
>     iMember3 As Integer
> End Type

> Dim ex As VB6_EXAMPLE

> Set ex = Nothing

> This doesn't work. Short of iterating through each member of the UDT, is
> there an easy way to initialize the members to Empty?

> BB



Mon, 12 Dec 2005 08:15:19 GMT  
 Clearing members of a UDT

Quote:

> You can keep an empty copy and set that to ex, or use a function that
> returns an empty copy and set that to ex.

Or if you make it dynamic, a ReDim will do it...

Each time you execute the ReDim statement, all the values currently
stored in the array are lost. Visual Basic resets the values to the
Empty value (for Variant arrays), to zero (for numeric arrays), to a
zero-length string (for string arrays), or to Nothing (for arrays of
objects).



Mon, 12 Dec 2005 09:26:29 GMT  
 Clearing members of a UDT
Bob,

Here is the easiest way to clear it, period.

'populate
ex.sMember1 = "some data"

'clear it
dim TheClearman as VB6_EXAMPLE
ex = TheClearman

That was pretty easy, huh?

--
Frank

Quote:
> What is the easiest way to clear each member of a UDT. Something like:

> Public Type VB6_EXAMPLE
>     sMember1 As String
>     bMember2 As Boolean
>     iMember3 As Integer
> End Type

> Dim ex As VB6_EXAMPLE

> Set ex = Nothing

> This doesn't work. Short of iterating through each member of the UDT, is
> there an easy way to initialize the members to Empty?

> BB



Mon, 12 Dec 2005 10:28:23 GMT  
 Clearing members of a UDT

"Bob Brown" asked:

Quote:
> What is the easiest way to clear each member of a UDT. Something like:

> Public Type VB6_EXAMPLE
>     sMember1 As String
>     bMember2 As Boolean
>     iMember3 As Integer
> End Type

> Dim ex As VB6_EXAMPLE

a) Dim ex As VB6_EXAMPLE

dim tmp as VB6_EXAMPLE
ex = tmp

b) Dim ex(100) As VB6_EXAMPLE
erase ex

c) Dim ex() As VB6_EXAMPLE
Redim ex()

Gunter Schmidt



Tue, 13 Dec 2005 18:10:18 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. passing UDT to a class member in an ole server

2. Clear collection of all members?

3. How can i clear the MSHFLEXGRID without CLEAR - Como limpar a GRID sem usar CLEAR

4. Help with UDT - Converting a UDT to a string Variable

5. Help with UDT - Converting a UDT to a string Variable

6. UDT to ByteArray and back to UDT

7. MSDN Members Helping Members criticism

8. For a bind combo box with display member and value member set

9. Language Suggestion: Default member for single-member structures

10. copy collection member’s data to another member

11. Enumerate Local Group Members and Identify Domain of Members

12. How to copy an object to another member by member

 

 
Powered by phpBB® Forum Software