Results 1 to 4 of 4

Thread: Specify a VB DLL location instead of registring?

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2002
    Location
    a cave
    Posts
    9

    Specify a VB DLL location instead of registring?

    i ave created a dll and a tester program but the program cannot find the entry point stringEd

    dll: [class module]

    VB Code:
    1. Option Explicit
    2. Public Function stringEd()
    3.     stringEd = "hello cheecky"
    4. End Function

    tester program:

    declaration statement in module:

    VB Code:
    1. Declare Function stringEd Lib "C:\fabian\VB Projects\Mine\dll try\stringEd.dll" () As String
    VB Code:
    1. Private Sub Command1_Click()
    2. MsgBox stringEd()
    3. End Sub

    thanx all!
    Last edited by JC Denton; Jun 4th, 2004 at 06:01 AM.
    Ur all xperts? Im a rookie, u were a rookie once too, so what happened?

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758
    VB Dlls are COM Components. The Declare Function ... statement is for accessing "standard" dlls, usually written in C/C++, like the windows api.

    With COM components you need to include a refererence to the dll in your project, create an "instance" of your class and then call the class properties/methods.

    References - Project -> References menu

    VB Code:
    1. Private Sub Command1_Click()
    2.     Dim oMyClassInstance as MyClassProject.MyClassName
    3.     Set oMyClassInstance = MyClassProject.MyClassName
    4.  
    5.     msgbox oMyClassInstance.StringEd
    6.  
    7.     Set oMyClassInstance = Nothing 'releases memory
    8. End Sub

  3. #3

    Thread Starter
    New Member
    Join Date
    Sep 2002
    Location
    a cave
    Posts
    9
    Thanx Brucevde

    How can i make it so that the app will always be accustomed that the dll is in the same dir.... or e.g.

    app.path & "\resources\stringEd.dll"
    Ur all xperts? Im a rookie, u were a rookie once too, so what happened?

  4. #4
    Hyperactive Member
    Join Date
    Sep 2001
    Location
    San Jose, Ca. - USA
    Posts
    302
    Originally posted by JC Denton
    Thanx Brucevde

    How can i make it so that the app will always be accustomed that the dll is in the same dir.... or e.g.

    app.path & "\resources\stringEd.dll"
    you would have to use late-binding.

    What brucevde is talking about is called early-binding. It's called early-binding because you app will have a reference to the dll before your app is compiled.

    late-binding allows you to create com objects in you app without it having a reference before your app is compiled. However, you still need to know the library and class names. But I don't think you can specifiy the filepath of the dll, I'm pretty sure that the vb runtime will search the registry for its filepath.

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