The simplest example of compiling and calling DLL in VB. NET, and the compiling example of vb. netdll

Source: Internet
Author: User

The simplest example of compiling and calling DLL in VB. NET, and the compiling example of vb. netdll

DLL (Dynamic Link Library) is a very useful thing. It is very important to develop large projects, because when many people cooperate in development, they can assign a task to each person and use DLL to complete it, when combined, there will be no conflict. Here is the simplest DLL compiling and calling example. I am not very familiar with it.

First, Open VB. NET, select the class library, and change the name to test.
Then enter the following code:

Public Class test

Public Function test (ByVal a As Long, ByVal B As Long) As Long

Return a + B

End Function

End Class

After saving, generate the DLL file.




This is the simplest DLL. The following is an example of calling this DLL.

Create a project and click "project" --> Add reference




Find the generated DLL and double-click it.



After adding a reference, nothing seems to happen. Then, we enter the following code:

Imports test. test

In this way, the DLL class is included.

Then we define a class

Dim test As New test. test

In this way, you can use the functions in it. The following is a program example.

Imports test. test

Public Class Form1

Private Sub Form1_Load (ByVal sender As System. Object, ByVal e As System. EventArgs) Handles MyBase. Load

Dim test As New test. test

MsgBox (test. test (1, 2 ))

End Sub

End Class




Run the program. You can see that the functions in the DLL are called.

This is the simplest DLL example. We can integrate some complex code into the DLL, which will be easier to upgrade or reuse later.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.