关于您的文章“如何在VB6中将.NET类与列表一起使用"! [英] About your article "How To Use a .NET Class with Lists in VB6"!!

查看:124
本文介绍了关于您的文章“如何在VB6中将.NET类与列表一起使用"!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读了你的文章,我以为我终于找到了我要寻找的东西,但这还不够:( ..

我正在尝试使用您的方式使用集合从VB6调用我的C#DLL,但是当我尝试从C#dll函数分配新集合时,它不起作用,它给了我这两个错误之一:类型不匹配"或参数不可选" ..我会写我的代码,请您在尝试找出问题的答案时给我一个答案...

在C#:

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
  }
 }
}


我注册了该dll,并将其作为ref放入vb.net项目"forvbuseWrapper"中.在这里是:


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



我注册了该dll,并将其作为ref放在下面的VB6项目中:



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



注意:我试图将参数设为可选,但没有用!
我真的希望您能对此有所帮助,我是应届毕业生,这是我新工作的第一个项目的重要组成部分.
还是谢谢你.
Saleem.



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.

推荐答案

如果您将问题发布到文章下方的论坛下,效果会更好.这样,文章作者将得到通知,并会为您提供帮助.
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.


这篇关于关于您的文章“如何在VB6中将.NET类与列表一起使用"!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆