|
-
Oct 17th, 2008, 08:52 AM
#1
Thread Starter
Frenzied Member
[2008] Class Project - Need help with making one
Hi,
I am all new to the Class project and this is my first one.
I have a few bits of code that I am always using in projects and I never get them right first time so I thought it would make sense to make a bunch of dlls containing them for easy use and when I have finished them I will make them available for free through my website however having a bit of a problem getting them to work.
I am not to sure where and how to put things so they can be used by the program using the DLL.
Firstly how do I declare varbiles to be accessed and modified by a program
I tried just at the begging of the class doing:
Public variblename as String()
i also tried putting them in a module and declaring them public but when in the module my program doesn't see them and when they are in the class it sees them but says it can't access them.
Secondly how do I declare the sub so that the program can launch it? I tried a Public Sub and a Public Function.
Thanks,
Max
-
Oct 17th, 2008, 09:05 AM
#2
Re: [2008] Class Project - Need help with making one
In general, what you described all sounds workable. You need to access everything through the library name, though. Thus if you create a class library called MyLib, then you create instances of the forms with:
NewForm = New MyLib.MyForm
At that point, everything should behave as it would normally. If you still can't see public members, then something else is going on.
My usual boring signature: Nothing
 
-
Oct 17th, 2008, 09:32 AM
#3
Re: [2008] Class Project - Need help with making one
you need to set a reference to your class library project from your main exe project. Even if they are in the same solution, they can't see eachother via code unless you set a reference.
If they are both part of the same solution, you need to go to add reference for your exe, and then there should be a "projects" tab where you can just select the class library project and it will reference it from your exe. If they are not part of the same solution, then you likely would need to do the same thing, but go to the browse tab instead of the projects tab, and find the compiled class library dll. I recommed putting them in the same solution for easy debugging though.
-
Oct 17th, 2008, 09:55 AM
#4
Thread Starter
Frenzied Member
Re: [2008] Class Project - Need help with making one
Ok, well I added a reference and used Imports But I have just added a declaration for it like Shaggy said and it's no longer got an error. Is this correct:
Code:
Imports EmailHandling
Imports EmailHandling.EasyEmailer
Imports EmailHandling.EasyEmailer.Sender
Public Class Form1
Dim EmailHand As New EmailHandling.EasyEmailer.Sender
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
EmailHand.ToAddress = "[email protected]"
EmailHand.Send()
End Sub
End Class
Thats the windows form project that is talking to my dll I know naming is bad but its only an exmaple.
And here is a bit from my class project:
Code:
Imports System.Net.Mail
Namespace EasyEmailer
Public Class Sender
Public ToAddress As String ' Put the To Address Here
Public Sub Send()
'code to send the email here
End Sub
End Class
End Namespace
Thanks,
-
Oct 17th, 2008, 10:00 AM
#5
Re: [2008] Class Project - Need help with making one
looks like you are doing it correctly.
-
Oct 17th, 2008, 10:07 AM
#6
Thread Starter
Frenzied Member
Re: [2008] Class Project - Need help with making one
Thanks for your help then. Will mark it as resolved.
So hopefully by then end of the year my developer section of my site should be up and running and I should have a small collection of DLLS :-) Will post a copy of the link on my sig when it is.
-
Oct 17th, 2008, 01:08 PM
#7
Re: [2008] Class Project - Need help with making one
I don't think you need all those Imports statements since you are fully decorating the variable declaration. I never use Imports, because I prefer to fully decorate declarations, but if you use the Imports statements, then this should be sufficient:
Dim EmailHand As New Sender
My usual boring signature: Nothing
 
-
Oct 17th, 2008, 01:12 PM
#8
Re: [2008] Class Project - Need help with making one
 Originally Posted by Shaggy Hiker
I don't think you need all those Imports statements since you are fully decorating the variable declaration. I never use Imports, because I prefer to fully decorate declarations, but if you use the Imports statements, then this should be sufficient:
Dim EmailHand As New Sender
so do you actually remove all the project level imports too??
-
Oct 17th, 2008, 02:28 PM
#9
Re: [2008] Class Project - Need help with making one
No, I leave them, but I do generally fully decorate the names, even if I don't need to. With intellisense, and being a fast typist, there is little cost to doing so, and I find it easier to remember what I was doing when I come back to the code later.
My usual boring signature: Nothing
 
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
|