Results 1 to 5 of 5

Thread: Class Library

  1. #1

    Thread Starter
    Hyperactive Member Dorothy's Avatar
    Join Date
    Feb 2001
    Posts
    310

    Question Class Library

    I tried out my first class Library in .NET.
    Did the following:
    1. File >New>Class library

    2. Added this code:

    Public Class Class1
    Public Sub funk()
    MsgBox("anand called")
    End Sub
    End Class

    3. F5 (Run application) with an exe.
    which had the following code:

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim a As New Object()
    a = CreateObject("ClassLibrary1.Class1")
    End Sub

    But when I click the button It says: Cannot create ActiveX component.

    Any help?

    Note: It succesfully creates a Dll in Debug and Bin Directory.

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Try early binding instead.

    Make a reference in the text program to the dll. Then dim your object as the class type instead of as the generic object.

    VB Code:
    1. 'after the reference is set
    2. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    3.    Dim a As New NamespaceOfClassHere.Class1()
    4.    a.funk()
    5. End Sub

  3. #3
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    Yeah you definitely want to use early binding.There is really no need to use late binding in your case. Using late binding would give you a performance hit because any method calls on a late bound object would have to be resolved at runtime vs at compile time.

  4. #4

    Thread Starter
    Hyperactive Member Dorothy's Avatar
    Join Date
    Feb 2001
    Posts
    310

    Unhappy

    It does'nt work either. I get the same error

  5. #5
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Are you sure you used the right namespace? You can find the namespace by right clicking on the project and going to its properties, it should look like the attached. Then the reference should take care of it.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width