Results 1 to 4 of 4

Thread: [RESOLVED] Clear a privat type variable.

  1. #1

    Thread Starter
    Addicted Member reacen's Avatar
    Join Date
    Jul 2009
    Location
    c:\windows\system32\gdi32.dll
    Posts
    243

    Resolved [RESOLVED] Clear a privat type variable.

    Hi,

    Anyone knows how to clear a privat type variable?

    Example:

    Code:
    '//Clear string variable:
    MyDATA$ = ""
    MyDATA$ = VbNullString
    
    
    '//Clear long variable:
    MyNUM& = 0
    How about clearing a private type variable (that have like a million types) in just one line?

    Code:
    Private Type TYPE1
       X1 As String
       X2 As Long
       X3 As Byte
       X4 As Integer
       'etc...
    End Type
    
    
    Private Sub Form_Load()
    
    Dim MyVAR As TYPE1
    MyVAR.X1 = "Teste"
    
    '//Clearing:
    MyVAR = Nothing
    Set MyVAR = Nothing
    MyVAR = Empty
    
    MsgBox MyVAR.X1   '// Should return nothing ("").
    
    End Sub
    
    '...
    
    
    'None of these 3 clearing lines work, I know.
    How do we do it in vb6? (Please don't tell me that I have to clear each Variable of that type manually? )
    DoEvents

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Clear a privat type variable.

    Ok, then I won't tell you that.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Re: Clear a privat type variable.

    This probably is not the proper way, but a quick and dirty way could be to create a new variable of the TYPE1 (on creation it will be empty) then assign it to the one you want to clear

    Dim MyVAR As TYPE1
    Dim MyVarClear As TYPE1

    MyVAR.X1 = "Teste"
    MyVAR = MyVarClear

  4. #4

    Thread Starter
    Addicted Member reacen's Avatar
    Join Date
    Jul 2009
    Location
    c:\windows\system32\gdi32.dll
    Posts
    243

    Re: Clear a privat type variable.

    Verry good idea baja_yu! Thank you!
    DoEvents

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