Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 101
Default Clearing all values in a User Defined Type variable

I have:

Public Type TPETC_COLS
Sort As Integer
AStart As Integer
RStart As Integer
SStart As Integer
RComplete As Integer
SComplete As Integer

End Type

But in the middle of the code I want to ensure all values in the type are
set to 0, I just want to know if there is an easier way to do this rather
than declaring each one as 0. Thanks.

--
*********************
J Streger
MS Office Master 2000 ed.
MS Project White Belt 2003

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Clearing all values in a User Defined Type variable

On way would be to declare a dummy variable as the same type. Then use lset
to reset

sub abc(
b as TPETC_COLS
mydum as TPETC_COLS

' work with b, never touch mydum

' now to reset

lset b = mydum

' b is now reset

End Sub


If you have a fixed array of these variables and you want reset them all,
then you can use erase


sub abc(
b(0 to 10) as TPETC_COLS


' work with b, never touch mydum

' now to reset all the type variables in the array

erase b

' all variables in b are now reset

End Sub

--
Regards,
Tom Ogilvy


"J Streger" wrote:

I have:

Public Type TPETC_COLS
Sort As Integer
AStart As Integer
RStart As Integer
SStart As Integer
RComplete As Integer
SComplete As Integer

End Type

But in the middle of the code I want to ensure all values in the type are
set to 0, I just want to know if there is an easier way to do this rather
than declaring each one as 0. Thanks.

--
*********************
J Streger
MS Office Master 2000 ed.
MS Project White Belt 2003

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 101
Default Clearing all values in a User Defined Type variable

Thank you Tom. :)
--
*********************
J Streger
MS Office Master 2000 ed.
MS Project White Belt 2003



"Tom Ogilvy" wrote:

On way would be to declare a dummy variable as the same type. Then use lset
to reset

sub abc(
b as TPETC_COLS
mydum as TPETC_COLS

' work with b, never touch mydum

' now to reset

lset b = mydum

' b is now reset

End Sub


If you have a fixed array of these variables and you want reset them all,
then you can use erase


sub abc(
b(0 to 10) as TPETC_COLS


' work with b, never touch mydum

' now to reset all the type variables in the array

erase b

' all variables in b are now reset

End Sub

--
Regards,
Tom Ogilvy


"J Streger" wrote:

I have:

Public Type TPETC_COLS
Sort As Integer
AStart As Integer
RStart As Integer
SStart As Integer
RComplete As Integer
SComplete As Integer

End Type

But in the middle of the code I want to ensure all values in the type are
set to 0, I just want to know if there is an easier way to do this rather
than declaring each one as 0. Thanks.

--
*********************
J Streger
MS Office Master 2000 ed.
MS Project White Belt 2003

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
Returning Values From a User-Defined Type BobbyMurcerFan[_2_] Excel Programming 2 March 26th 06 07:58 PM
"User-defined type not defined" message in Excel RW1946 Excel Discussion (Misc queries) 0 August 31st 05 12:14 PM
Workspace faux user-defined type not defined Chris S[_2_] Excel Programming 3 November 11th 04 05:51 PM
User-defined data type; Error: Only User-defined types... tiger_PRM Excel Programming 1 July 18th 04 03:32 PM
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 01:18 AM.

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

About Us

"It's about Microsoft Excel"