Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

sample dll in vb.net

vadoolavadoola Member Posts: 1
Hi,

I am looking for the steps required to create a simple dll in vb.net

Thanks,
vadoola

Comments

  • FallenFallen Member Posts: 32
    : Hi,
    :
    : I am looking for the steps required to create a simple dll in vb.net
    :
    : Thanks,
    : vadoola
    :

    Do you mean a) how to call it from vb.net or b)how to actually create a dll?

    a) right click on the References part of the Solution Explorer, then add reference, now use the browse button to locate the dll you wish to use. Now you'll notice the new dll added to the reference list. Ok now go into your coding view and right at the top before Public Class add:

    Imports (without the <>) you'll notice a drop down box to help.

    Now you'll need to create an object to handle it.

    Dim oTest as new type()

    Then you would use it like a normal control

    oTest.something etc etc.

    b) Start a new project (Class Library Project)

    Now create what ever functions you want like normal, but make sure that anything that needs to interact with the outside world, will need to be made Public, and not Private. If you wanted to create something that retrieved a value from the program and then added 5 to it, and then returned the value you would do something like this:

    Public Class Class1
    Public Function RtnValue(ByVal iValue As Integer) As Integer
    RtnValue = iValue + 5
    End Function
    End Class

    and that would basically be it.

    Example for both a and b.

    Create the above dll, and name it dllTest.dll
    add it to the main projects references.
    Then at the top of the form, add:

    Imports dllTest

    then after the Public Class :

    Dim odlltest as new Class1()

    Then create a button, and add this:

    MsgBox(otest.RtnValue(5))

    Than will send the value 5 to the dll, and run the function to add 5 to it, and then return the new value.

    I hope that helps, and you can understand my rantings ;-)

    If not, or you need further help, email me at VB@fallensworld.co.uk
  • Chris BrownChris Brown USAMember Posts: 4,496 ✭✭

    _ \ http://forcoder.org \ free ebooks and video tutorials about / C#, JavaScript, Objective-C, Python, Assembly, Ruby, PL/SQL, Go, Scratch, R, Delphi, Java, Perl, MATLAB, Visual Basic, Visual Basic .NET, C, C++, PHP, Swift Ada, Scheme, Crystal, D, Dart, Bash, LabVIEW, Clojure, Awk, COBOL, SAS, VBScript, Hack, ABAP, Erlang, FoxPro, Lisp, Lua, F#, Rust, Transact-SQL, Alice, Scala, Fortran, Julia, Kotlin, Prolog, ML, Logo, Apex / ___________

Sign In or Register to comment.