Yes, the good old dlls. I have tried some examples and read topics but I can never get the dll to work. I just want to try something simple.
I have a form with 3 textboxes and a button. Once I click the button textboxes 1 and 2 have their strings added and inserted into textbox 3. My dll simple adds the two strings. Can any one point me in the right direction
Thank you,
Wellnow

I need some help creating a simple dll
scorange
Well if the assembly/dll does not exist and "AddNumbers" is a function in that DLL and you call it, you will get an exception which you try to execute that function, since you are importing the namespace it will import but when trying to access that class/function in that DLL, it will throw a filenotfound exception if the file does not exist, so that should work.
As a test, just copy your .exe file into a different directory, in its own on your computer and run it. Now press Button1. you should see a messagebox now, with that the exception message since this will be your catch block being executed
Steven Galione
robertje
Oh hey, wadda ya know ! That worked nicely! Actually I has to change the Function to Shared Function though but it works!
Thank you ahmedilyas!
Tyrael Tong
Imports FVxDll.Class1
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
TextBox3.Text = AddNumbers(TextBox1.Text, TextBox2.Text)
Catch Ex As Exception
MsgBox(Ex.Message)
End Try
End Sub
End Class
BrianYDP
can you tell us what doesnt work Have you been able to create the DLL in VB.NET
I'm not sure about the Express Editions however when I had created a simple DLL to add 2 numbers and return back the result, once the DLL was compiled, I simply added that DLL as a reference (right click on your "References" in the winforms project and go to add reference, select the browse tab and double click the DLL).
Once added, you should be able to access that dll usually in the format of:
DllAssemblyName.ClassName
So you would need to create an instance of a class in that dll:
Dim theClass as new DllName.ClassName()
then access its public members like so:
Dim result as Integer = theClass.AddNumbers(1, 2)
reichard
Public Class Class1
Function AddNumbers(ByVal X As Integer, ByVal Y As Integer)
AddNumbers = X + Y
End Function
End Class
I keep finding information about dlls for VB6 but when I used VB6 I still couldn't get it to work!
Whether or not the dll structure is right, I still don't know how to call it in my Application. All the tutorials are about a user control for a button. And If I remember right, the MSDN Help Files on my computer have an example for that. But again. I want to make a simple dll and application that adds 2 numbers.
Does this make any since I don't want to confuse any one.
abzA
makes perfect sense and I did just that without any problems. I'm not sure if the express edition has this but when you create a new project, do you get a template called something like "Class library" this is the one you need to make a dll. The class files are the same really, its just the project type that needs to be a library to make a DLL. if not, sure for one online in the new project dialog...if it doesnt exist then nothing much you can do as its a limit in the express edition IDE. However you can still use the VB.NET compiler, vbc.exe, in the .NET Framework directory in the Windows folder and use the command line to compile a file/project into a dll. Not entirely sure how to do this but when typed in a command prompt "vbc.exe / " after navigating to the directory it should give you a list of commands
anyway lets do everything step by step, do you get the class library project template
irl-barse
coconut113651
no worries, glad I could help :-)
now if the assembly/dll does not exist then placing a try catch block on where you are trying to create the class. you should get a FileNotFound exception. What happens when you try this Can you show the code you are using
TJ2007
Hum actually, if any of my dlls are really needed then I could make a function that checks if they exists using IO namespace.