Results 1 to 4 of 4

Thread: Unload integer variable possible ???

  1. #1

    Thread Starter
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538

    Talking

    Thought it about time I tidied up my coding. I know you can use:
    Code:
    Dim WrdApp as Word.application
    Dim StrCaption as string
    
       'some code here
    
    Set WrdApp = Nothing
    Set StrCaption = nothing
    To unload the variables at the end of a sub to free up ram & virtual memory, make tider code & speed the rest of the program up. Fine.

    Now, how the @#{>/~!!!! do you unload an integer??? I've tried:
    Code:
    Set i = nothing
    i = nothing
    unload i         'which I should've guessed wouldn't work.
    I just can't get rid of them! (i above is an integer variable by the way). Thanks!

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  2. #2
    Fanatic Member Jerry Grant's Avatar
    Join Date
    Jul 2000
    Location
    Dorset, UK
    Posts
    810
    Just set it at '0' this will reinitialise it. If it is a procedure level variable it will be destroyed on exit of the procedure.

    Code:
    'Numeric:  
    intNum = 0
    
    'String:
    strText = vbNullString
    
    'Array:
    Erase arrData
    
    'Object:
    Set objItem = Nothing
    Jerry Grant................tnarG yrreJ
    Website: <JG-Design></.net>
    Email: [email protected]
    Working towards a bug free world......
    (Not a Microsoft employee)

  3. #3
    Fanatic Member
    Join Date
    Oct 2000
    Location
    London
    Posts
    1,008
    You do not need to set any of the intrinsic data types to Nothing. This is only for object pointers.

    Integers (and Strings etc.) will be automatically disposed of. Setting it to zero will not really do anything (except change the value).

    Cheers,

    P.
    Not nearly so tired now...

    Haven't been around much so be gentle...

  4. #4

    Thread Starter
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    Thank all, will bear that in mind.

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width