C# static methods -> .dll -> VB6 fail to work

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Okay i manage to convert the C# class library into dll, and enable com interop.

I basically can call c# methods from vb6 with this as long i add references to the .net project (e.g TestProject)

Private Sub Command1_Click()
Dim myObject As TestProject.ClassA
Set myObject = New TestProject.ClassA
Dim test as String
test = myObject.PrintHello()
MsgBox test
End Sub

in C# if i code this,

public string PrintHello()
{
return "hello";
}

so i can get to call the method from vb6 with the solution on top!
----

But if i use try to use static in the method,

public static string PrintHello()
{
return "Hello";
}

i receive an error in VB6

coz i called directly like

Dim test2 as String
test2 = ClassA.PrintHello() 'fail to work

Compile Error: Variable not defined - cannot find ClassA

Any idea, please?

Thanks.
 
=?Utf-8?B?Q2h1YSBXZW4gQ2hpbmc=?= said:
Dim test2 as String
test2 = ClassA.PrintHello() 'fail to work

Compile Error: Variable not defined - cannot find ClassA

I dont have all you code, but shouldnt it be:

test2 = TestProject.ClassA.PrintHello()

?

Check your imports as well.


--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Develop ASP.NET applications easier and in less time:
http://www.atozed.com/IntraWeb/
 
Back
Top