Click here to Skip to main content
15,887,485 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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.
Posted

1 solution

I would be better if you post the question under the forum below the article itself. That way the article writer will be notified and will help you out.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900