I read your article,and i thought that i finally found what i'm searching for,but it was not enough:(..
I'm trying to use your way to call my C# DLL from VB6,using collections,and it's not working,when i try to assign a new collection from the C# dll function,it gives me one of these two errors: "Type mismatch",or "argument not optional".. I'll write my code and please when you can try to figure out the problem and gime me an answer...
IN C#:
namespace forvbuse
{
public class myclass
{
public int giveCol(out Collection coll)
{
coll=new Collection();
coll.Add(1,"one",null,null);
coll.Add("string","str",null.,null);
return coll.count
}
public Collection giveCol()
{
Collection collec=new Collection();
coll.Add(1,"one",null,null);
coll.Add("string","str",null.,null);
return collec
}
}
}
I registered this dll and put it as ref in the vb.net project"forvbuseWrapper"..here it is:
Public class FWmyclass
Private _myclass As New forvbuse.myclass
public Sub New()
MyBase.New()
End Sub
Public Function giveColCount() As Integer
Dim col as New Collection()
col=_myclass.giveVol()
return col.count
End Function
Public Function giveCol() As Collection
Dim col=New Collection()
col=_myclass.giveCol()
return col
End Function
End Class
I registered this dll and put it as ref in the VB6 Project below:
Private Sub Form_Load()
Dim a As New forvbuseWrapper.FWmyclass
Dim col As New Collection
Dim count As Integer
count=a.giveColCount() 'this one works,it makes count=2
col=a.giveCol() 'gives me "Argument Not Optional"
Set col=a.giveCol() 'gives me "Type mismatch"
End Sub
NB:I tried to make the argument optional,but it didn't work!
I really wish you can help me in this,I'm a fresh graduate,and this is a big part of my first project in my new job...
Thank you anyway..
Saleem.