views:

192

answers:

1

Hi!

How to call a function in vb.net DLL from VBScript?

I did the following: - I create public class named Class1 in vb.net.

  • I go to Visual Studio 2008 Command Prompt and go to my class dll - C:\Myapp\bin\Debug and type following command tlbexp myDLL.dll after that i get message Assembly exported to C:\Myapp\bin\Debug\myDLL.tlb

  • After this I type following command regasm myDLL.dll and i get following message RegAsm : warning RA0000 : No types were registered

This is how my class look like:

Public Class Class1
   Public Function ADD(ByVal first As Integer, ByVal sec As Integer)
        Dim abc As Integer
        abc = first + sec
        Return abc
    End Function
    Public Function Subtraction(ByVal first As Integer, ByVal sec As Integer)
        Dim abc As Integer
        abc = first - sec
        Return abc
    End Function
end class

Where I am making mistake, and which is the easiest way to use vb.net from vbscript!

Many thanks!

A: 

You are on the correct path. Does your class have a default contructor? Does your class have a public method?

Also, right click on your project in Visual Studio. I believe there is a "register for COM" or "make COM visible" checkbox to save you a few steps.

Kris Krause
I update my answer, and write my class code.
In your project properties, in the Compile section, you should check the "Register for COM interop" box.
Rick Mogstad