VB.NET Tutorial - Create a DLL / Class Library (Visual Basic .NET)
Вставка
- Опубліковано 16 лип 2024
- In this Visual Basic .NET tutorial I will be showing you how to create and use your own DLL (Dynamic Link Library) in your VB.NET projects.
We will create a DLL file for managing form graphics and use that DLL to draw images to forms and form controls.
TUTORIAL FEATURES:
DLL - Library, Namespace, Class
Graphics - System.Drawing, Image
Form Controls - Button, PictureBox
Class - Image Manager
Thank you for this nice and basic tutorial on Visual Basic.NET dll files.
This is a very interesting tutorial. It helps a lot for a beginner like me. Thank you for uploading tutorials like this.
Beautiful tutorial. It helps me understand a lot about DLL. Thanks.
Well Done
Totally love you, apart from the coding stuff. Keep it up, you're one of the rare, good guys on UA-cam.
Thank you! I really appreciate that. :-D
thanks.. it's very helpful :)
Nicely done Thanks
excellent presentation
Thanks :D
thank you🧿
This is the best project for me thz VB Toolbox
+Ly Watanak I'm very happy that it was helpful! :-)
I'm a newbie and would like to know if you have an example using the windows OpenFile Dialog to be able to choose any image from the directory. This have been a very interesting tutorial especially for a beginner like me. Thanks.
31:33 LOOOL Where is that came from? I love your tuts!! No1 on my list
What we have to do for importing xls, csv and xlsx file
thank you
Very nice tutorial. Can you organize the functions in modules to keep the length of the DLL manageable? I am thinking of something like having each class being a module. Like have a class of constants, a class of orbit parameters, and a class of antenna parameter functions, and class of plots. It would look better I think if all the functions for one class was in its own module. Otherwise I see a dll being thousand of lines long.
C# and Java got a lot of similarities :O
At least in the coding language.
I made a .dll file with an XNA base. So all I would need to do is move that ".dll" file into any project that I could use those same boilerplate classes?
how or where i could find or create the comwrap.dll and toolkitpro1201vc90.dll file missing from my computer
Hello, how can i create Activex control in VB.net (VS2010). I just want to create simple speedometer in VB.net
First o all great job! I hope you're still making videos like this. You're doing humanity a great service! Thank you sir! :D
The Image in the PictureBox doesn't load a second time after I've loaded and then deleted it once. Why is that? Shouldn't it appear/reappear and disappear every time i click on the Draw and Delete buttons? If not, how do I make it work like that? Thanks!
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
PictureBox1.Image = Nothing
PictureBox1.BackColor = Color.Empty
PictureBox1.Invalidate()
End Sub
Works for me
5:00 Reference is not being added to it. So I'm unable to do System. Drawing < please assist.>
might be a stupid question, however... is it possible to export a dll from visual basic and use it in c#? since both languages are .NET?
for example i like the easy md5 function from visual basic and want to use it in c#.
Yes but dont ask me how
I already forgot I asked this. well I published a dll for hashing encrypting etc written in c# and it can be used in both f# and vb aswell. :) But thanks for responding
i loved this!!!!!!!!!!!!!, super buddy, keep uploading.
+shabeer shah I'm glad you liked it! Thank you much for the feedback. :-D
+VB Toolbox mine is not working here's my code: class 1
Imports System.Drawing
Namespace GDI
Public Class IMmanager
Public images As New Dictionary(Of String, Image)
Public Sub loadImage(name As String, path As String)
If images.ContainsKey(name) Then
Exit Sub
Else
Try
Dim i As Image = Image.FromFile(path)
images.Add(name, i)
Catch ex As Exception
End Try
End If
End Sub
Public Sub removeImage(name As String)
If images.ContainsKey(name) Then images.Remove(name)
End Sub
Public Sub drawImage(surface As Object, name As String, position As Point, Optional size As Point = Nothing)
Try
If images.ContainsKey(name) Then
Dim G As Graphics = surface.creategraphics
If size.IsEmpty Then
G.DrawImage(images(name), position)
Else
G.DrawImage(images(name), New Rectangle(position.X, position.Y, size.X, size.Y))
End If
End If
Catch ex As Exception
End Try
End Sub
End Class
End Namespace
for form1
Imports GFX.GDI
Public Class Form1
Private ImgMan As IMmanager
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
ImgMan.loadImage("Home", "Home.png")
'ImgMan.loadImage("deadpool", "deadpool.png")
End Sub
Private Sub Form1_Paint(sender As Object, e As PaintEventArgs) Handles Me.Paint
ImgMan.drawImage(Me, "Home", New Point(0, 0), New Point(Me.Width, Me.Height))
End Sub
End Class
+VB Toolbox did you looked at the project?
+george gallimore Not yet, sorry. I don't get much time to program on the weekend and it was a holiday, as well.
+george gallimore I looked at the project and it looks like you were missing the "New" keyword when you declared ImgMan in your form.
Is should look like this:
Private ImgMan As New IMmanager
good
I always use Option Strict On and the line Dim G as Graphics = Surface.CreateGraphics gives a late binding error. How can I get rid of this error (any ideas)?
I did a little test with Option Strict On and was able to get rid of the error by changing the parameter type from Object to Graphics.
The call changes slightly.
I used: *Public Sub DrawImage(Surface As Graphics, Name As String,....*
Then I changed the lines below to this:
Try
If Images.ContainsKey(Name) Then
Dim G As Graphics = Surface
Then to call the Sub, use the object AND its CreateGraphics method for the parameter.
Example:
ImgMan.DrawImage(*Me.CreateGraphics*, "Bolt", New Point(0, 0), New Point(Me.Width, Me.Height))
FromFile brings an exception error it does not belong to System.Drawing
plz give me the code for a sample program to create a user defined DLL
create dll vb visual studio 2019 use in excel
This tutorial also serves very well for review. The only issue I encountered with VS2019 was the Navigation Bar was missing. I found this answered at stackoverflow.com/questions/4240523/visual-studio-client-objects-events-drop-down-list-missing
Hope you mark their answer as ACCEPTED
this is real
I can't be the only one who thinks you kinda sound like BadBoyHalo
Only much less exuberant and with waaaaaaaaay fewer views. 😅
@@VBToolbox you’ll get there soon, keep your head high :)
it's not working for me, I follow your every step and all that i am getting is a BIG "X" in my form.
give me some hint,
+george gallimore Hello, George. :-) You're using relative pathing for your image source. Did you ensure that "deadpool.png" is in your application folder ("bin/debug")?
i will recheck and get back to you, thanks in advance.
it still doesn't work, here am sending you the project: www.dropbox.com/s/ypykelqrqsqv9df/Image%20Dll%20File.rar?dl=0