|
-
Aug 1st, 2002, 02:15 PM
#1
Thread Starter
yay gay
How to call a function of a class library?
how do i call a function of a class library in vb.net?
-
Aug 1st, 2002, 04:32 PM
#2
Make on object of one of the classes and then call the function you want.
-
Aug 1st, 2002, 05:34 PM
#3
Member
Unless the function is declared as 'shared' then you don't need an object instance
-
Aug 1st, 2002, 05:55 PM
#4
Thread Starter
yay gay
how do i do that ( i want code plz ) tks
-
Aug 1st, 2002, 06:02 PM
#5
Member
In your class library where you have
Public Sub SomeFunction(ByVal somevar As String)
just change it to
Public Shared Sub SomeFunction(ByVal somevar As String)
-
Aug 1st, 2002, 06:20 PM
#6
Thread Starter
yay gay
but how do i call it? the topic says how to call not how to make it...
-
Aug 1st, 2002, 06:27 PM
#7
Member
Edneeis answered that earlier, but if you need the actual syntax
<project name>.<class name>.<funtion name>
eg.
projectname.myclass.myfunction(myargs)
unless you import projectname.myclass in which case you could just use myfunction(myargs) and if the class is in the same project as you are calling it from then you can leave off the project name.
Does that make it clear?
Last edited by Matt02; Aug 1st, 2002 at 06:31 PM.
-
Aug 1st, 2002, 06:37 PM
#8
Thread Starter
yay gay
C:\Documents and Settings\JBRANCO\My Documents\Visual Studio Projects\WindowsApplication27\Form1.vb(47): Name 'classlibrary2' is not declared.
...
-
Aug 1st, 2002, 06:43 PM
#9
Thread Starter
yay gay
let me explain that i want that an EXE file calls a DLL's file so , it must connect to another file
-
Aug 1st, 2002, 07:19 PM
#10
Did you add a reference to it?
You still have to add references in .NET although it isn't reliant on the registry as much.
-
Aug 1st, 2002, 07:32 PM
#11
Thread Starter
yay gay
do i really have to do that? what if i want my prog to dinamicly add them at run-time..?
-
Aug 1st, 2002, 07:32 PM
#12
Thread Starter
yay gay
my idea was to load all the "plugins" that are in the /plugin/ directory....
-
Aug 1st, 2002, 08:43 PM
#13
I'm not positive but I believe you can still use CreateObject. One good thing about .NET is you don't have to register the plugins before you use them.
-
Aug 2nd, 2002, 07:17 AM
#14
Thread Starter
yay gay
i tryed old way but it seems not to work , or at least not the same way:
[Highlight=VB]
dim LOL as object
LOL = CreateObject("project2.class1")
LOL.Test(arg1,arg2)
[Highlight=VB]
also tryed with Set LOL but it seems not to work too
-
Aug 2nd, 2002, 08:46 AM
#15
Frenzied Member
Dude you have to add a reference to the class library and you aslo have to declare an instance of the class you want to use explicitly. If the class is shared then it does not have to be instantiated.
Now if you want to load a library, you have check out the System.Reflection namespace. Another thing check out the System.Activator Class which is the key to late binding.
You are going to be using the Assembly class to load the library during run time, getting the type declared in that library and instatntiating and running those types.
Good luck
-
Aug 2nd, 2002, 10:00 AM
#16
Thread Starter
yay gay
-
Aug 2nd, 2002, 10:50 AM
#17
Thread Starter
yay gay
isnt there any tuturial around who could explain this with some detail?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|