Problem adding to collection only when complied, not in IDE 
Author Message
 Problem adding to collection only when complied, not in IDE

Has anayone seen this before ?
I have a strange strange issue with a collection. When it is run in IDE  the
objects can be added the collection. No problem at all.
When the "business-dll" is compiled it seems to be inpossible to add objects
to the collection. No error message but the collection stays empty.
I'm running with VB6 Sp5
Regards,
Arjan

'This is a part of the client code :
Set mWorkers = CreateObject(cBUSINESWORKERS)
Dim tContact As CMSbusiness.clsBusinessContact
Dim tWorker As CMSbusiness.clsBusinessWorker
For Each tWorker In mWorkersForOrg
    Set tContact = New CMSbusiness.clsBusinessContact
    tContact.ReadPersonDetails tWorker.PersonID
    'next line is NOT WORKING when the business DLL is compiled !!!!!
    mWorkers.Add tWorker
    Set tContact = Nothing
    Next

'This is the add-fuction in the business-part:
Public Function Add _
( ByVal aWorker As CMSbusiness.clsBusinessWorker ) As Boolean
    aWorker.CreateKey
    mWorkers.Add aWorker, aWorker.Key
    Add = True
    Exit Function
End Function

Friend Sub CreateKey()
    mKey = CStr("#" & CStr(mPersonID))
End Sub



Sun, 26 Sep 2004 14:34:33 GMT  
 Problem adding to collection only when complied, not in IDE

Quote:
> Set mWorkers = CreateObject(cBUSINESWORKERS)
>     'next line is NOT WORKING when the business DLL is compiled !!!!!
>     mWorkers.Add tWorker

What is 'cBUSINESWORKERS'?


Sun, 26 Sep 2004 23:32:37 GMT  
 Problem adding to collection only when complied, not in IDE
Const cBUSINESSCONTACTS = "CMSBusiness.clsBusinessContacts"


Quote:
> > Set mWorkers = CreateObject(cBUSINESWORKERS)
> >     'next line is NOT WORKING when the business DLL is compiled !!!!!
> >     mWorkers.Add tWorker

> What is 'cBUSINESWORKERS'?



Mon, 27 Sep 2004 15:05:57 GMT  
 Problem adding to collection only when complied, not in IDE
mWorkers is not a collection but an object of type
CreateObject(cBUSINESWORKERS).
The error is probably in this object.

Why are you using a Constant in a CreateObject like this anyway? I am not
even sure whether it is valid code. This gives late binding - better to use
Set mWorkers = New CMSBusiness.clsBusinessContacts



Quote:
> Has anayone seen this before ?
> I have a strange strange issue with a collection. When it is run in IDE
the
> objects can be added the collection. No problem at all.
> When the "business-dll" is compiled it seems to be inpossible to add
objects
> to the collection. No error message but the collection stays empty.
> I'm running with VB6 Sp5
> Regards,
> Arjan

> 'This is a part of the client code :
> Set mWorkers = CreateObject(cBUSINESWORKERS)
> Dim tContact As CMSbusiness.clsBusinessContact
> Dim tWorker As CMSbusiness.clsBusinessWorker
> For Each tWorker In mWorkersForOrg
>     Set tContact = New CMSbusiness.clsBusinessContact
>     tContact.ReadPersonDetails tWorker.PersonID
>     'next line is NOT WORKING when the business DLL is compiled !!!!!
>     mWorkers.Add tWorker
>     Set tContact = Nothing
>     Next

> 'This is the add-fuction in the business-part:
> Public Function Add _
> ( ByVal aWorker As CMSbusiness.clsBusinessWorker ) As Boolean
>     aWorker.CreateKey
>     mWorkers.Add aWorker, aWorker.Key
>     Add = True
>     Exit Function
> End Function

> Friend Sub CreateKey()
>     mKey = CStr("#" & CStr(mPersonID))
> End Sub



Mon, 27 Sep 2004 17:20:11 GMT  
 Problem adding to collection only when complied, not in IDE
Thanks you all.
The problem is fixed now. I think it had something to do with a
compatibility issue with an older version in the registry.
Does someone have a clear article about compatibility issues and what
exactly is done in the registry ?
How do cleanup the registry manually (without having the old dll and using
regsvr32) ?
Regards,
Arjan

Quote:
> mWorkers is not a collection but an object of type
> CreateObject(cBUSINESWORKERS).
> The error is probably in this object.

The object itselft contains a collection which can be filled this way.
Working this way is also discribed in MSDN-VB Programmaers Guide-"Creating
Your Own Collection Class"

Quote:
> Why are you using a Constant in a CreateObject like this anyway? I am not
> even sure whether it is valid code. This gives late binding - better to
use
> Set mWorkers = New CMSBusiness.clsBusinessContacts

I think you're right. I will check if i can change this. It is valid code
but i think using New is better indeed.


Mon, 27 Sep 2004 20:04:20 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Controls.Add not updating Collection

2. Can't run a problem coded in vb4.0 when complied in vb5.0

3. Problem w/complied code

4. ado access problem in complied dll

5. Problem w/complied code

6. Problem w/complied code

7. Collection.Add and Collection.Item question?

8. Problems with adding Items in collections

9. Problem adding UDT to Collection

10. VB Collections - Accessing the collection, not the item.

11. Why VBA.Collection and Not VB.Collection?

12. ? Collection add object -> usercontrol add control

 

 
Powered by phpBB® Forum Software