Results 1 to 33 of 33

Thread: [RESOLVED] Strange Class Clone problem

  1. #1

    Thread Starter
    Frenzied Member some1uk03's Avatar
    Join Date
    Jun 2006
    Location
    London, UK
    Posts
    1,513

    Resolved [RESOLVED] Strange Class Clone problem

    Something very strange going on, which used to work!

    I have a class with references to it.
    myClass.cls

    Code:
    LeftClass(5) = new myClass
    RightClass(5) = new myClass
    When i do:

    Code:
    LeftClass(2) = RightClass(4).Clone
    LeftClass does NOT get copied. All properties have EMPTY STRINGS!!!

    VB Mixing up address pointers or something?



    Code:
    Public Function Clone() As myClass
    'Return a copy of this instance
    'Create a blank copy
      Set Clone = New myClass
      
      With Clone
           .Name = xName
           .pID = xID
           .Channels = xChannels
      End With
    End Function
    _____________________________________________________________________

    ----If this post has helped you. Please take time to Rate it.
    ----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.



  2. #2
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    2,191

    Re: Strange Class Clone problem

    Shouldn't that be "Set LeftClass(2)=RightClass(4).Clone"?
    One System to rule them all, One IDE to find them,
    One Code to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    For health reasons i try to avoid reading unformatted Code

  3. #3

    Thread Starter
    Frenzied Member some1uk03's Avatar
    Join Date
    Jun 2006
    Location
    London, UK
    Posts
    1,513

    Re: Strange Class Clone problem

    Quote Originally Posted by Zvoni View Post
    Shouldn't that be "Set LeftClass(2)=RightClass(4).Clone"?
    Nope. That throws an error 438: Object doesn't support this property or method
    _____________________________________________________________________

    ----If this post has helped you. Please take time to Rate it.
    ----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.



  4. #4
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    13,167

    Re: Strange Class Clone problem

    Well you do not call functions using . unless of course the function is part of the class
    seems like it should be
    Code:
    Set LeftClass(2)=Clone(RightClass(4))
    And of course the function would need to accept the class as a parameter.
    Last edited by DataMiser; Jun 29th, 2020 at 07:35 AM.

  5. #5
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    13,167

    Re: Strange Class Clone problem

    Looking further you are using different variable names for your assignments so I really have no idea what you are doing there, not enough code given, do not know where the function is or what those variables may hold.

  6. #6

    Thread Starter
    Frenzied Member some1uk03's Avatar
    Join Date
    Jun 2006
    Location
    London, UK
    Posts
    1,513

    Re: Strange Class Clone problem

    I've now also tried: rightClass(5).Clone(RightClass(4))


    I think there's something wrong with VB AddressSpace ?

    Because it used to be working! it's just NOT copying the properties across.
    Last edited by some1uk03; Jun 29th, 2020 at 08:22 AM.
    _____________________________________________________________________

    ----If this post has helped you. Please take time to Rate it.
    ----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.



  7. #7
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    3,844

    Re: Strange Class Clone problem

    Create a basic sample program which shows your problem.
    If use these kind of methods a lot and never ran into problems

  8. #8
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    6,248

    Re: Strange Class Clone problem

    Quote Originally Posted by Arnoutdv View Post
    Create a basic sample program which shows your problem.
    If use these kind of methods a lot and never ran into problems
    ditto
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  9. #9
    PowerPoster
    Join Date
    Feb 2017
    Posts
    2,246

    Re: Strange Class Clone problem

    Quote Originally Posted by some1uk03 View Post
    When i do:

    Code:
    LeftClass(2) = RightClass(4).Clone
    LeftClass does NOT get copied. All properties have EMPTY STRINGS!!!
    If that "worked" in the past without the Set statement ( Set LeftClass(2) = RightClass(4).Clone ) you are doing something strange.

    Perhaps the class has some default property defined and that's why you don't get an error message, but the class members values were in fact copied somewhere else (that now it is not in the code any more).

  10. #10
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,044

    Re: Strange Class Clone problem

    You are going to have to post a play project. I'd bet you are doing something wrong and VB is not the reason.

    In its simplest form, this does not cause an error on:
    Code:
    Private Sub Command1_Click()
        Dim lc As New Class1  ' pointless if going to set it to some clone anyway
        Dim rc As New Class1  
        rc.Name = "Hello World"
        Set lc = rc.Clone
        MsgBox lc.Name
    End Sub
    simple class1
    Code:
    Dim xName As String
    Dim xID As Long
    Dim xChannels As Long
    
    
    Public Function Clone() As Class1
    'Return a copy of this instance
    'Create a blank copy
      Set Clone = New Class1
      
      With Clone
           .Name = xName
           .pID = xID
           .Channels = xChannels
      End With
    End Function
    
    Public Property Get Name() As String
        Name = xName
    End Property
    Public Property Let Name(v As String)
        xName = v
    End Property
    
    Public Property Get pID() As Long
        pID = xID
    End Property
    Public Property Let pID(v As Long)
        xID = v
    End Property
    
    Public Property Get Channels() As Long
        Channels = xChannels
    End Property
    Public Property Let Channels(v As Long)
        xChannels = v
    End Property
    Last edited by LaVolpe; Jun 29th, 2020 at 12:23 PM.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  11. #11

    Thread Starter
    Frenzied Member some1uk03's Avatar
    Join Date
    Jun 2006
    Location
    London, UK
    Posts
    1,513

    Re: Strange Class Clone problem

    LaVolpe: The code is exactly as you quickly summed up there, except the msgbox returns ""

    the project is quite huge.. so I'm still looking..
    _____________________________________________________________________

    ----If this post has helped you. Please take time to Rate it.
    ----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.



  12. #12
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,044

    Re: Strange Class Clone problem

    In the sample code above, the msgbox does not return ""
    I assume you meant that in your project, you are not getting things copied. And since the sample I posted works and yours does not, there is a key difference. We'll need a stripped down example to look at.

    By the way: key difference between Set and not using Set

    Set Me.Picture = Me.Icon ' calls Picture Set and Icon Get
    Me.Picture = Me.Icon ' calls Picture Let and Icon Get
    the last example would cause an error because a Set is required to assign objects. However, we coders can get creative and have our Let properties call a Set internally. This is why an error isn't generated. Picture Let property is calling a Picture Set method internally.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  13. #13
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,044

    Re: Strange Class Clone problem

    If your project is huge, maybe it is using the Implements keyword and the class you are trying to clone is an implementation? In that case, it is possible that you think the class is another class and the properties you expect are not in the implemented class but the class that is implementing it?

    However if the variable on the LHS is being set to the same class type returned by the Clone method, you shouldn't be having any issues. I'd recommend placing a breakpoint on the clone method and walking the code to see where the error occurs.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  14. #14
    PowerPoster
    Join Date
    Feb 2017
    Posts
    2,246

    Re: Strange Class Clone problem

    Quote Originally Posted by some1uk03 View Post
    LaVolpe: The code is exactly as you quickly summed up there
    Quote Originally Posted by LaVolpe View Post
    Code:
        Set lc = rc.Clone
    Quote Originally Posted by some1uk03 View Post
    Code:
    LeftClass(2) = RightClass(4).Clone
    ....

  15. #15
    PowerPoster
    Join Date
    Feb 2017
    Posts
    2,246

    Re: Strange Class Clone problem

    Quote Originally Posted by some1uk03 View Post
    Quote Originally Posted by Zvoni View Post
    Shouldn't that be "Set LeftClass(2)=RightClass(4).Clone"?
    Nope. That throws an error 438: Object doesn't support this property or method
    No...

  16. #16
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    2,191

    Re: Strange Class Clone problem

    Have you compared the ObjPtr of both after assignment?
    Meaning:
    Code:
    LeftClass(2)=RightClass(4).Clone
    
    Debug.Print ObjPtr(LeftCLass(2))
    Debug.Print ObjPtr(RIghtClass(4).Clone)
    One System to rule them all, One IDE to find them,
    One Code to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    For health reasons i try to avoid reading unformatted Code

  17. #17
    PowerPoster
    Join Date
    Feb 2017
    Posts
    2,246

    Re: Strange Class Clone problem

    Quote Originally Posted by Zvoni View Post
    Have you compared the ObjPtr of both after assignment?
    Meaning:
    Code:
    LeftClass(2)=RightClass(4).Clone
    
    Debug.Print ObjPtr(LeftCLass(2))
    Debug.Print ObjPtr(RIghtClass(4).Clone)
    In that code the ObjPtr will be different because every time you call Clone it instantiate a new object.

    But a better test would be:

    Code:
    Debug.Print ObjPtr(LeftCLass(2))
    LeftClass(2)=RightClass(4).Clone
    Debug.Print ObjPtr(LeftCLass(2))
    That must print the same ObjPtr because the object of LeftClass(2) is never replaced due to the lack of the Set statement.
    (BTW, there is no possibility to have a Let anywere there, they are just variables)

  18. #18
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,044

    Re: Strange Class Clone problem

    Code:
    LeftClass(2)=RightClass(4).Clone
    That line should error: Object doesn't support this property or method
    Why? Because the .Clone method is returning an object and Set is not used. If it doesn't error then default properties are in play. And only the default properties are being cloned, not the entire class.

    here's a modified example with default properties in play. In effect, the clone call ends up like this:
    lc.Instance = rc.Clone.Instance, no other clone properties set
    Code:
    Private Sub Command1_Click()
        Dim lc As New Class1  ' pointless using NEW if going to set it to some clone anyway
        Dim rc As New Class1
        rc.Name = "Hello World"
        rc.Instance = ObjPtr(rc)
        lc = rc.Clone
    ' notice that the left hand clone has no name but has Instance. This is because without Set above, only the default property is updated
        MsgBox lc.Name & vbCrLf & rc.Name
        MsgBox lc.Instance & vbCrLf & rc.Instance
    End Sub
    Class1
    Code:
     ' you must use IDE menu: Tools | Procedure Attributes
     ' select Instance property, then click Advanced, then set Procedure ID to Default
    
    Dim xName As String
    Dim xID As Long
    Dim xChannels As Long
    Dim xInstance As Long
    
    Public Property Get Instance() As Long
        Instance = xInstance
    End Property
    Public Property Let Instance(v As Long)
        xInstance = v
    End Property
    
    
    Public Function Clone() As Class1
    'Return a copy of this instance
    'Create a blank copy
      Set Clone = New Class1
      
      With Clone
           .Name = xName
           .pID = xID
           .Channels = xChannels
           .Instance = xInstance
      End With
    End Function
    
    Public Property Get Name() As String
        Name = xName
    End Property
    Public Property Let Name(v As String)
        xName = v
    End Property
    
    Public Property Get pID() As Long
        pID = xID
    End Property
    Public Property Let pID(v As Long)
        xID = v
    End Property
    
    Public Property Get Channels() As Long
        Channels = xChannels
    End Property
    Public Property Let Channels(v As Long)
        xChannels = v
    End Property
    Last edited by LaVolpe; Jun 29th, 2020 at 02:16 PM.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  19. #19
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    6,248

    Re: Strange Class Clone problem

    some1uk03, the first block of code you gave us was:

    Quote Originally Posted by some1uk03 View Post
    Code:
    LeftClass(5) = new myClass
    RightClass(5) = new myClass
    Personally, I don't even understand how that could work.
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  20. #20
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,044

    Re: Strange Class Clone problem

    @Elroy, obviously he is setting RightClass(5) properties elsewhere in code.

    @some1uk: If you run my modified example a couple posts up, I think that is what you are seeing. If SET is not used, LET is called and if no property is being queried, i.e., just the class name, no dot + method name, then the class' default property is returned.
    ex: MsgBox Class1 will display its default property if it has one else it will error

    leftClass = rightClass.Clone is same as leftClass.[_default] = rightClass.Clone.[_default]
    Set leftClass = rightClass.Clone is creating a new class

    In object explorer (F2) within the IDE, default properties have that hand icon with a little checkmark in icon's top left corner. You can look at your classes in object explorer and see which have default properties and which do not.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  21. #21
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    6,248

    Re: Strange Class Clone problem

    IDK, but I think we're all taking pot-shots in the dark with entirely too little information. IMHO, some1uk03 is also struggling with the concepts of instantiation and creating additional references, as well as creating "clones" (which, the way he's got it, should be another instantiation and not another reference to the same object). But even that's a guess at this point.

    Also, the fact that some1uk03 made this statement...

    Quote Originally Posted by some1uk03 View Post
    I think there's something wrong with VB AddressSpace ?
    ...makes me think he's not examining his own code closely enough. Unless explicit manipulation of object pointers is performed, or explicit manipulation of QueryInterface, Addref, or Release is performed, I've never seen VB6 have any problems with instantiating or un-instantiating objects (or copying their properties).

    Until some1uk03 is willing to provide a small "complete" example that illustrates the failure, I'm not sure there's much we can do. Also, the act of putting together those types of examples often illustrates the programming error.

    EDIT: And by the way, even the title of the thread illustrates a weakness in understanding. It should be "Strange Object Clone problem". The class is what is used to instantiate the object, and not the object itself.

    EDIT2: And some1uk03, I apologize if I'm coming off as harsh. Maybe I'm just getting a bit stir-crazy being in lock-down for so long. I do hope you get it figured out.
    Last edited by Elroy; Jun 29th, 2020 at 02:46 PM.
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  22. #22
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,044

    Re: Strange Class Clone problem

    I think it's a simple matter of not using Set. I think the cloned class has a default property. That explains everything IMO.

    In addition, depending on how complex those classes are, a class default property can be referencing another class with its own default property and so on. Not using Set when wanting to return an object has unexpected consequences when default properties are in play. Maybe that's a reason why converting VB code to .Net can fail when default properties are used implicitly vs. explicitly.

    But yes, a learning curve seems to be in play too.
    Last edited by LaVolpe; Jun 29th, 2020 at 03:05 PM.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  23. #23
    PowerPoster
    Join Date
    Feb 2017
    Posts
    2,246

    Re: Strange Class Clone problem

    Quote Originally Posted by LaVolpe View Post
    Code:
    LeftClass(2)=RightClass(4).Clone
    That line should error: Object doesn't support this property or method
    Quote Originally Posted by LaVolpe View Post
    @Elroy, obviously he is setting RightClass(5) properties elsewhere in code.
    Quote Originally Posted by LaVolpe View Post
    I think it's a simple matter of not using Set.
    That's what I said in post#9

  24. #24
    PowerPoster
    Join Date
    Feb 2006
    Posts
    21,031

    Re: Strange Class Clone problem

    Yeah, I also suspect the problem is failure to Set (using implied Let instead) along with default Properties.


    Slightly OT:

    Normally a "Clone" method would make use of a Friend Sub call to copy everything in one go. Less overhead than copying each Property one by one and additional internal-state values can be copied as well.

    I suspect Friend tends to confuse people because they have fallen out of the habit of writing separately-compiled DLLs, OCXs, and ActiveX EXEs. When used within the same compilation unit they're globally visible there.

    VB can confuse newbs because it is unusual. Sort of a Big Wheel equipped with a shop full of power tools. You find naive coders trying to propel it with the bench grinder, lube the wheels with shellac, pound nails with a screwdriver, etc. etc. That's why after VB5 there was no longer a "kid's edition" ("Standard"), only Pro and Ent. You're supposed to have an education.

  25. #25

    Thread Starter
    Frenzied Member some1uk03's Avatar
    Join Date
    Jun 2006
    Location
    London, UK
    Posts
    1,513

    Re: Strange Class Clone problem

    Guys thanks for all the input....
    The issue has been resolved now.

    #Believe it or not closed/opened VB a few times and everything was back to normal!

    Now both options work again!

    Code:
    LeftClass(2)=RightClass(4)
    and
    LeftClass(2)=RightClass(4).Clone
    Code:
    SET LeftClass(2)=RightClass(4).Clone  is raising an error 438
    --------------
    Then again I've now re-written the workflow to update the class as ref


    i/e


    Code:
    RightClass(4).clone  LeftClass(2)
    
    '//in class
    Public Sub Clone(tmpOBJ as myClass) 
      With tmpOBJ 
           .Name = xName
           .pID = xID
           .Channels = xChannels
      End With
    End Function
    _____________________________________________________________________

    ----If this post has helped you. Please take time to Rate it.
    ----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.



  26. #26
    PowerPoster
    Join Date
    Feb 2017
    Posts
    2,246

    Re: Strange Class Clone problem

    Quote Originally Posted by dilettante View Post
    Slightly OT:

    Normally a "Clone" method would make use of a Friend Sub call to copy everything in one go. Less overhead than copying each Property one by one and additional internal-state values can be copied as well.
    I don't understand what you mean with "to copy everything in one go", do you mean using CopyMemory or what?

  27. #27
    PowerPoster
    Join Date
    Feb 2017
    Posts
    2,246

    Re: Strange Class Clone problem

    Quote Originally Posted by some1uk03 View Post
    Code:
    SET LeftClass(2)=RightClass(4).Clone  is raising an error 438
    That makes no sense. if you get the error on that line, it could only happen if the Clone method name is misspelled, but you would have to get the same error without Set.

    If the error happens inside the Clone method, you also would have to get the same error without Set.

    Could you make a small sample project to show that error?

    PS: try to always post "working" sample projects to show what you mean with your questions. While doing that, probably half of the times you'll find the problem yourself (and we don't have to guess too).

  28. #28
    PowerPoster
    Join Date
    Feb 2006
    Posts
    21,031

    Re: Strange Class Clone problem

    Quote Originally Posted by Eduardo- View Post
    I don't understand what you mean with "to copy everything in one go", do you mean using CopyMemory or what?
    No, just a subroutine call passing data names to be copied into ByRef. One call is more efficient than 5 or 10 or 50 Property calls.

  29. #29
    PowerPoster
    Join Date
    Feb 2017
    Posts
    2,246

    Re: Strange Class Clone problem

    OK, I see.

  30. #30
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    32,829

    Re: [RESOLVED] Strange Class Clone problem

    [RESOLVED] Strange Class Clone problem
    Wait, suddenly it's resolved? What was the issue? I NEED CLOSURE! (not to be confused with clojure, which is a wholy different skill set.)
    I feel like I just read a who-dunnit novel and the last chapter is missing.

    -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??? *

  31. #31
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    2,191

    Re: [RESOLVED] Strange Class Clone problem

    Quote Originally Posted by techgnome View Post
    Wait, suddenly it's resolved? What was the issue? I NEED CLOSURE! (not to be confused with clojure, which is a wholy different skill set.)
    I feel like I just read a who-dunnit novel and the last chapter is missing.

    -tg
    it was the stable-boy.......
    One System to rule them all, One IDE to find them,
    One Code to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    For health reasons i try to avoid reading unformatted Code

  32. #32
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    6,248

    Re: [RESOLVED] Strange Class Clone problem

    Personally, I sort of think this whole thread should be deleted. For someone who's trying to learn about VB6 classes and objects, this thread is just going to confuse the crud out of them.
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  33. #33
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    2,191

    Re: [RESOLVED] Strange Class Clone problem

    Quote Originally Posted by Elroy View Post
    Personally, I sort of think this whole thread should be deleted. For someone who's trying to learn about VB6 classes and objects, this thread is just going to confuse the crud out of them.
    Oh my!
    and now you‘re introducing databases into the equation
    One System to rule them all, One IDE to find them,
    One Code to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    For health reasons i try to avoid reading unformatted Code

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