Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default clearing a user-defined Type variable

Declare an instance of your type, but don't set any of its values. The
elements of the Type will be the default values (0s or vbNullStrings or
Emptys). Then use LSet to set your fillled out Type to the default values.
E.g.,

Public Type MyType
L As Long
S As String
End Type


Sub AAA()
Dim Filled As MyType
Dim Default As MyType
Filled.L = 12345
Filled.S = "some string"
Debug.Print Filled.L, Filled.S
LSet Filled = Default ' set to default values
Debug.Print Filled.L, Filled.S
End Sub



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)



"Martin" wrote in message
...
How do I do it in one line of code? Currently I can only go through every
defined property and set each (as relevant) to zero, null or
zerolength-string. Setting the variable equal to Null or Nothing won't
work.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Clearing all values in a User Defined Type variable J Streger Excel Programming 2 April 27th 06 08:01 PM
Help: Compile error: type mismatch: array or user defined type expected lvcha.gouqizi Excel Programming 1 October 31st 05 08:20 PM
User-defined data type; Error: Only User-defined types... tiger_PRM Excel Programming 1 July 18th 04 03:32 PM
Word.Document - user defined type not defined jowatkins[_7_] Excel Programming 0 January 20th 04 08:46 AM
User Defined Type Structure - want it to be variable not numeric literal WyoCracker Excel Programming 1 July 21st 03 09:28 PM


All times are GMT +1. The time now is 11:04 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"