A Dynamic-Link Library is a non executable program made of one or more files, which contains classes, procedures, and/or other resources that other programs can use. Because it is not an executable, it doesn’t need an entry point or the main() procedure and it usually ends with .dll
Well, you can read more about Dynamic link libraries(dlls) on msdn or wikipedia.
In this post I’ll show you how to create a VB.Net DLL from the command line.
First you need to set up your system to use the vbc compiler. If you do not know how to do this, please read my previous post here. So from now on I’ll assume you have set up your compiler and we are ready to go.
Steps:
- Open notepad, create a class, call it Person and save it as a VB file (Person.vb) . For this post we’ll create a simple Person class. See the code for the class at the end of the post below.
>>CodeListing No.1 – The Person Class
- Create a new folder in your main drive (in my case C:\) and call it PersonLibrary. Save the above class in this folder.
- Click Start > Run > type cmd and click OK to open the command prompt.
- Change to the PersonLibrary directory as shown in the image below.

How to Create a Dynamic-Link Library from the command line.
- There are two options. The first one is you create a library that has the same name as the source file.
- To create a Dll that has the same name as the source file, at the command prompt type the following command.
vbc /target:library Person.vb
- The command is vbc /target:library nameOfSourceFile.vb notice the space after vbc and the other space after library. Make sure you include them.
- Browse to the PersonLibrary folder and you’ll see that the Person.dll dynamic-link library has been created. See the image below.

2. The other option is that you can provide your own name for the library.
- To create a Dll that has your own desired name, at the command prompt type the following command.
vbc /target:library /out:PersonLibrary.dll Person.vb
- The command is vbc /target:library /out:DesiredNameOfLibrary.dll nameOfSourceFile.vb
- Now browse to the PersonLibrary folder and you’ll see the newly created dll with our custom name PersonLibrary.dll, as well as the old one, Person.dll

And thats all there is to it. You are done and you have your libraries and you can distribute them now or use them from an application.
How to use the Library.
Before you use the library you simply have to import it into your project and add it as a reference using the command line when compiling.
- Open Notepad and type in the following code
Imports System
Imports PersonLibrary
Module MainModule
Sub Main()
Dim p As New Person("Mike F", "Masao")
p.Addresses(0) = "6032, Olacity, Arusha"
p.Addresses(1) = "Tanzania"
p.Citizenship = "Tanzanian"
p.BirthDate = #8/21/1982#
Console.WriteLine("Full Name: " & p.FullName("Mr."))
Console.WriteLine("Address1: " & p.Addresses(0))
Console.WriteLine("Address2: " & p.Addresses(1))
Console.WriteLine("Citizenship: " & p.Citizenship)
Console.WriteLine("Age: " & p.Age)
Console.Read()
End Sub
End Module
- Save the file as MainProgram.vb under our PersonLibrary folder.
- Now go back to the command prompt and issue the following command, which will add the library as a reference to the project and then compile the MainProgram code to an executable.
vbc /reference:PersonLibrary.dll MainProgram.vb
- The command is vbc /reference:NameOfLibrary.dll NameOfMainProgram.vb
- After the above steps, browse again to the PersonLibrary folder and you’ll see your libraries and your MainProgram.exe executable file as seen in the image below.

- Now double click the MainProgram.exe file and you should see the following output on your screen.

And we are done.
So now you can create your own libraries by using just notepad and the command prompt.
Hope this was helpful. Till next time, yours truly.
CodeListing No.1 – The Person Class
Public Class Person
'Fields
Public FirstName As String
Public LastName As String
Public m_BirthDate As Date
'You can define up to 4 addresses for this person
Public m_Addresses(3) As String
Public Citizenship As String = ""
Sub New(ByVal firstname As String, ByVal lastname As String)
Me.FirstName = firstname
Me.LastName = lastname
End Sub
Public Property BirthDate() As Date
Get
Return m_BirthDate
End Get
Set(ByVal value As Date)
m_BirthDate = value
End Set
End Property
Function FullName(Optional ByVal title As String = "") As String
FullName = ""
'use the title if provided
If title <> "" Then FullName = title & " "
'append first and last names
FullName &= FirstName & " " & LastName
End Function
'Age is a ReadOnly property
Public ReadOnly Property Age() As Integer
Get
Return Year(Now) - Year(m_BirthDate)
End Get
End Property
Public Property Addresses(ByVal index As Integer) As String
Get
If index < 0 Or index > UBound(m_Addresses) Then
Throw New IndexOutOfRangeException("Invalid address Index")
End If
Return m_Addresses(index)
End Get
Set(ByVal value As String)
If index < 0 Or index > UBound(m_Addresses) Then
Throw New IndexOutOfRangeException("Invalid address Index")
End If
m_Addresses(index) = value
End Set
End Property
End Class
I need help on writing dll using visual basic .net environment.
@Oluwadare,
This method works for VB.Net as well. However there is a more advanced way of doing this through visual studio.
Have a look here for an opening >> http://social.msdn.microsoft.com/forums/en-US/vbgeneral/thread/cc722e73-ebac-4d22-971b-ef34454418e0
Cheers
Pls I need help on creating visual image library using visual basic.net or visual basic 6 for inclusion in a project am working on. Thanks
Wonderful goods from you, man. I have understand your stuff previous to and you
are just too excellent. I actually like what you’ve acquired here, really like what you are stating and the way in which you say it. You make it entertaining and you still care for to keep it wise. I can’t
wait to read much more from you. This is really a tremendous web site.
I was wondering if you ever considered changing the structure of your site?
Its very well written; I love what youve got to say.
But maybe you could a little more in the way of content so people could connect with
it better. Youve got an awful lot of text for only
having 1 or two images. Maybe you could
space it out better?
I’ve learn some good stuff here. Definitely price bookmarking for revisiting. I surprise how so much effort you place to make any such wonderful informative web site.
Hi there I am so grateful I found your website, I really found you
by error, while I was looking on Digg for something else,
Anyways I am here now and would just like to say many thanks for a incredible post and a all round thrilling blog (I also love the theme/design), I dont have
time to look over it all at the minute but I have bookmarked it and also added
your RSS feeds, so when I have time I will be back to read more, Please
do keep up the fantastic work.
Hi there, just became aware of your blog through Google, and found that it’s really informative. I’m going
to watch out for brussels. I’ll appreciate if you continue this in future. Many people will be benefited from your writing. Cheers!
I have to thank you for the efforts you have put in penning this
site. I really hope to check out the same high-grade content from you in the future as well.
In truth, your creative writing abilities has motivated me to get my very own website now ;
)
If some one desires to be updated with most
recent technologies therefore he must be visit this website and be up to date
all the time.
If there is a change in the search engine algorithms, it is also
up to the service provider to keep a watch on such activities.
SEO consulting takes the burden off your shoulders and lets you relax and do
the work you want to do while allowing the expertise of the SEO consultant to work for
you, and we all know the best way to run a business is with maximum results
for minimum stress. You can then take a hard look at the companies
that come up for that particular keyword. Naturally, they will flock to your competitor who does.
A dedicated SEO expert will devote all the attention and effort
in enhancing the visibility of your website or business in the online world.
Examine in detail the shift in the customers’ rank, and progress in their positions. Some SEO firms focus on content spinning and submitting articles. Having realized that it is practically not possible to combat with SEO Next in terms of services and offerings at this point of time, rivals have started thinking of an easier alternative of being successful in their mission. Configure You – Tube settings by changing the default settings to your preferred and secure preferences. Numerous SEO services over competitive price for outsourcing your site online, but, would it be best to hire the locals if the nature of your business limits to your local as well. It is a sagacious process that has become even tougher with the continuous changes in the algorithm of the major search engines especially Google. Still hanging on. Let us assume that at this point you have 6 keywords. You can Google maps link for your website, which will be very helpful if any person search in images sections. Create a general, high-level category in which you want to manage all phrases’for example ‘global,’ ‘online,’ ‘channel,’ and so on.
SEO defined. Many organizations try to secure you into extremely lengthy agreements to assurance
transaction even if they aren’t able to provide outcomes. You will not even get to a 1 or 2 until Google has fully crawled your website or blog enough to give it a ranking. First of all a market survey is done by them as to know the competitors analysis. Addition and updation of fresh content always leads to arrival of increased traffic to your websites.
Hello my friend! I wish to say that this post is awesome,
nice written and come with almost all vital infos. I would like to see more posts like this .
Hi there, just wanted to say, I enjoyed this blog post.
It was inspiring. Keep on posting!
I all the time used to study paragraph in news papers but now
as I am a user of internet therefore from now I am using net
for content, thanks to web.