Tutorial - Visual Basic 2010 - How to make a dll/Class Library - L3GiT
This video is a tutorial on how to make a .dll also known as an application extension ALSO known as a Class Library in Visual Basic 2010 (.NET 4.0). If you are in need to know how to make a Class Library you probably already decent at programming, but if your not that is still okay as I went over some key features such as Sub and Subs being Private or Public as well as Functions being Private, Public and Public Shared.
Private Sub or Private Function:
If you see the word Private in front of something, it generally means that it can not be accessed outside of the class that it was made in.
Public Sub or Public Function:
If you see the word Public it means that it can be called outside of the class, but there are a few ways to do it depending on what type of Public it is.
Public Shared:
To know what Public means, please read the above definition. If you see Shared it and there is a Public in front of it, it means that you do not have to do any special declarations to access the Sub or Function. All you need to do is add the import the the dll.
*******NOTE*******
A Shared method (Sub/Function) can not access a method that is not shared, as well as for viscera.
Sub:
A method that does not return anything.
Function:
A method that has to return something. If there is no return value you may get an error.
If using a method that is not a Shared Method, you need to declare a new instance like this.
Dim Variable as new dll.class1
Where Variable is the name that you want to use as a reference, where dll is the physical name of the dll and class1 the name of the class which can be found at the very top of the code of the dll under the imports (If there are any)
If you have any other question, comments or request, please feel free to ask them and I will see what I can do. I am always looking for new videos to make. So please help me out and give me some requests.
ALSO, don't forget to Subscribe so you don't miss out on any upcoming videos that I upload.
CmptrPrgmr - L3GiT
Closed Caption:
yeah
lu two years computer program here today
i'm gonna be showing you how to make a
dll with visual basic 2010 first off to
open up visual basic or visual studio
any project in visual basic and have
select class library i'm just gonna name
mine tutorial LOL and i'm just going to
make some random functions in here and
write our subs and functions one is
going to be a privates a private
function and I call this one tests i'm
gonna have it as byval my valet as
integer then as string what this means
is this a is what's going to be used is
what can be carried on from when this
function is called and a string means it
returns a string and i'm going to have a
public shared sub and I called test one
I'm going to have a public function
called test2 have byval a as integer
string
then i'm going to have one more that we
confuse them
so okay and I'm gonna have on another
private shared function called test 35
ali-a as integer string that goes my dog
barking in the background like edit that
out
alright alright no we're not going to
have a shared things with shared if you
have a shared you can't call something
else has not shared if it's an anatomic
something that is not sure you can call
something that is shared right if you
see something that says private means it
can only be called inside the class so i
can't i can't call this function
anywhere outside of this class public
with public means i can call it outside
the class if it's shared home we'll get
into that a bit and I would put the
private function already got a private
function y mcmillan stupid right
I've so for the private function we're
going to have if they also this doesn't
have to be bought by valet can be
whatever you want and is not to be
interesting
engine either ok so if on a equals 1
then returned one else if a equals to
return
two
public shared sub causing here so i have
x value again in here about eight as
integer we're going to have if a equals
1 message box one else if a equals to
$OPERAND then
messagebox.show you guessed it to the
public function we're going to have if a
equals 1 then return tests a else if a
equals to return test a i'm going to
else return
nothing
ok so i have a forgot to another tree
method year so else return
nothing alright so when this sub is
called to see the message one or two
whatever whatever the equals when this
function is called is going to call this
function with this carried out into this
and if it equals 1 r this equals one is
going to return one to this function and
this can return on the answer back to
work being first called from it's hard
to explain what's you'll get the point
in a minute after you got your coat
finish doubts save its gonna save it so
I you save it and go to builds builds on
your project and open up another
instance of visual studio visual basic
in the project and make it on windows
form to call its tutorial gonna make a
little bit bigger then add two buttons
and one text box
the first button did you have almost
forgot
go to your solution Explorer click show
all files right click on preferences
click add reference to browse and browse
to your dl is located here
then I'll go to the top of the class
type in imports and then your dll put
dots and in class 1a class one is the
name of the class of course we're going
to have benefits if you have any armed
functions or subsets are not shared such
as this one you're going to need this
code dim and then have any variable you
want to call it a new class and as
tutorial dl dots class 1 which is the
same things that for this one now for
the first button i'm going to have its
to test one which was shared so i'm not
going to need to use this variable is to
tutorial LOL dots class one . test one
then text box one . text for the second
button and you have its have on message
box thing that you have new class which
is the variable up here that we created
a new class . test two and have textbox1
dots texts and their habits now let's
just run the code
you type in one
let me get one and where we got that
from was this one is calling test one
which is this right here i typed in 10
we carried on this one got current
carried through to the a and you got
checked right here if I equals 1 which
it did the message box one now if i type
in two message box too
oh yeah i forgot to on we're creating
the new creating on the variable . is
going to be as new
stop and run again see if it works
one and then put into and there we go
and how this is working
same thing as the other one lost in the
way to test the button to is test two
so the ones getting curates to the a
cartoon of the eighth here and is being
carried on to the private function
through here
Rick's returning test a and our tests
and this is tests and a is being carried
from here to here and if a equals one is
going to return one back to this and
return its back to what was called from
here type into work and if i type in
three or something else I really have no
clue what happens my doubts return
nothing and the statements nothing there
and nothing there
if you have any other questions comments
some requests or anything like that
please message me I'll be glad to help
you out to film this doesn't make any
sense to or need to explain it better
and not really going to explain things
right
I don't plan amounts but you have any
questions comments or questions on
please on ask them and I'll try to help
you out thanks for watching
Video Length: 10:16
Uploaded By: CmptrPrgmr
View Count: 20,873