2

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!

user261810
  • 41
  • 1
  • 4
  • 2
    See http://stackoverflow.com/questions/769332/how-to-call-c-dll-function-from-vbscript – Helen Feb 01 '10 at 11:15
  • When i try this regasm /codebase myDLL.dll i am getting The message: "The /codebase switch is intended to be used only with signed assemblies. Please give your assembly a strong name and re-register it. RegAsm : warning RA0000 : No types were registered" – user261810 Feb 01 '10 at 11:25
  • 1
    Check out http://www.geeksengine.com/article/create-dll.html. In particular the step **2. Configure project properties to make it COM visible**. – Stephen Quan Feb 07 '12 at 01:02

1 Answers1

0

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
  • 7,304
  • 2
  • 23
  • 26