473,378 Members | 1,346 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Using functions between projects

In one VB.Net 2003 solution, I have three projects (one in the installer
project and not relevant here). However, the other two are the ones where I
want to share some commone fucntions. One is a Windows Forms based app and
the other is a Windows Service. Is this possible?

TIA,
--
Anil Gupte
www.keeninc.net
www.icinema.com
Jan 1 '08 #1
10 1374

"Anil Gupte" <an*******@icinema.comwrote in message
news:OG**************@TK2MSFTNGP05.phx.gbl...
In one VB.Net 2003 solution, I have three projects (one in the installer
project and not relevant here). However, the other two are the ones where
I want to share some commone fucntions. One is a Windows Forms based app
and the other is a Windows Service. Is this possible?
You put the functions in a public class like this.

Public Class Test

Public Shared Function test(ByVal msg As String) As String

Return msg

End Function

End Class

Then you can do something like this with a Messagebox as an example.

Messagebox(Test.test("Help"))

You can put the Test class in your projects.

It's just an example.

Jan 1 '08 #2
Anil,

As long as you build them as Class Librarys you can do everything with the
public methods and properties in the resulting DLL's.

(You have to set a reference to that).

Cor

Jan 1 '08 #3

Personaly i would avoid shared methods , i believe it is bether coding
practice to construct an object and dispose of it when done with it
nowadays i implement the idisposable pattern in all of my custom classes and
use them with the using statement to make sure i am not wasting anny
resources

but as i said this is a personal opinion


"Mr. Arnold" <MR. Ar****@Arnold.comschreef in bericht
news:eF**************@TK2MSFTNGP04.phx.gbl...
>
"Anil Gupte" <an*******@icinema.comwrote in message
news:OG**************@TK2MSFTNGP05.phx.gbl...
>In one VB.Net 2003 solution, I have three projects (one in the installer
project and not relevant here). However, the other two are the ones
where I want to share some commone fucntions. One is a Windows Forms
based app and the other is a Windows Service. Is this possible?

You put the functions in a public class like this.

Public Class Test

Public Shared Function test(ByVal msg As String) As String

Return msg

End Function

End Class

Then you can do something like this with a Messagebox as an example.

Messagebox(Test.test("Help"))

You can put the Test class in your projects.

It's just an example.

Jan 1 '08 #4
On Jan 1, 12:15*pm, "Michel Posseth [MCP]" <msn...@posseth.comwrote:
Personaly i would avoid shared methods , i believe it is bether coding
practice to construct an object and dispose of it when done with it
nowadays i implement the idisposable pattern in all of my custom classes and
use them with the using statement to make sure i am not wasting anny
resources

but as i said this is a personal opinion
Why do you implement the disposable pattern on all custom classes?
That seems a little overkill - since it won't really buy you anything
unless your are making use of unmanaged resources.
--
Tom Shelton
Jan 1 '08 #5
since it won't really buy you anything
>unless your are making use of unmanaged resources.
Well it actually does give me something , variabels used inside a using
stament are out of scope as you leave the using statement
for grouping purposes this makes the code in my opinion a lot bether
readable .
also
i use a lot of data intensive resources , so with the using stament i can
write a class level table adapter use this in all my methods an get rid of
it through the idisposable pattern .

it also doesn`t hurt to implement idisposable , it just gives you some extra
coding options wich i like verry much
Michel

"Tom Shelton" <to*********@comcast.netschreef in bericht
news:24**********************************@l6g2000p rm.googlegroups.com...
On Jan 1, 12:15 pm, "Michel Posseth [MCP]" <msn...@posseth.comwrote:
Personaly i would avoid shared methods , i believe it is bether coding
practice to construct an object and dispose of it when done with it
nowadays i implement the idisposable pattern in all of my custom classes
and
use them with the using statement to make sure i am not wasting anny
resources

but as i said this is a personal opinion
Why do you implement the disposable pattern on all custom classes?
That seems a little overkill - since it won't really buy you anything
unless your are making use of unmanaged resources.
--
Tom Shelton
Jan 2 '08 #6
Are you sure - I am talking abuot sharing the same class and/or functions
between two separate executables?

Anyway, I will try it and let you know.

--
Anil Gupte
www.keeninc.net
www.icinema.com

"Mr. Arnold" <MR. Ar****@Arnold.comwrote in message
news:eF**************@TK2MSFTNGP04.phx.gbl...
>
"Anil Gupte" <an*******@icinema.comwrote in message
news:OG**************@TK2MSFTNGP05.phx.gbl...
>In one VB.Net 2003 solution, I have three projects (one in the installer
project and not relevant here). However, the other two are the ones
where I want to share some commone fucntions. One is a Windows Forms
based app and the other is a Windows Service. Is this possible?

You put the functions in a public class like this.

Public Class Test

Public Shared Function test(ByVal msg As String) As String

Return msg

End Function

End Class

Then you can do something like this with a Messagebox as an example.

Messagebox(Test.test("Help"))

You can put the Test class in your projects.

It's just an example.

Jan 3 '08 #7
So, I have to create a separate project to build a dll containing the shared
functions? Is there any example code out there on how to do this? Or even
on building a dll - preferably exposing more than one function?

Thanx,
--
Anil Gupte
www.keeninc.net
www.icinema.com

"Cor Ligthert[MVP]" <no************@planet.nlwrote in message
news:F0**********************************@microsof t.com...
Anil,

As long as you build them as Class Librarys you can do everything with the
public methods and properties in the resulting DLL's.

(You have to set a reference to that).

Cor

Jan 3 '08 #8

"Anil Gupte" <an*******@icinema.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
Are you sure - I am talking abuot sharing the same class and/or functions
between two separate executables?

Anyway, I will try it and let you know.
You really were not giving any particulars, but you should remember it, the
Shared keyword, look it up.

Jan 3 '08 #9

"Anil Gupte" <an*******@icinema.comwrote in message
news:eY**************@TK2MSFTNGP04.phx.gbl...
So, I have to create a separate project to build a dll containing the
shared functions? Is there any example code out there on how to do this?
Or even on building a dll - preferably exposing more than one function?
You make a Class Library project, the class is public, the functions in the
class are public, you compile the Class Library project to make the DLL,
that you set reference to the DLL in your project wanting to use the Dll,
and you insatiate the class object just like any other object to use its
methods.

<http://www.google.com/search?hl=en&q=creating+a+Class+Library+project+VB .net&btnG=Google+Search>

You can also include the project in a Solution a .sln with other projects
and set Project Reference to the project so that you can debug functions
being used by the project using the Class Library.
Jan 3 '08 #10
Thanx!

--
Anil Gupte
www.keeninc.net
www.icinema.com

"Mr. Arnold" <MR. Ar****@Arnold.comwrote in message
news:OK**************@TK2MSFTNGP02.phx.gbl...
>
"Anil Gupte" <an*******@icinema.comwrote in message
news:eY**************@TK2MSFTNGP04.phx.gbl...
>So, I have to create a separate project to build a dll containing the
shared functions? Is there any example code out there on how to do this?
Or even on building a dll - preferably exposing more than one function?

You make a Class Library project, the class is public, the functions in
the class are public, you compile the Class Library project to make the
DLL, that you set reference to the DLL in your project wanting to use the
Dll, and you insatiate the class object just like any other object to use
its methods.

<http://www.google.com/search?hl=en&q=creating+a+Class+Library+project+VB .net&btnG=Google+Search>

You can also include the project in a Solution a .sln with other projects
and set Project Reference to the project so that you can debug functions
being used by the project using the Class Library.


Jan 3 '08 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: hokiegal99 | last post by:
A few questions about the following code. How would I "wrap" this in a function, and do I need to? Also, how can I make the code smart enough to realize that when a file has 2 or more bad...
0
by: Marcos Rodríguez | last post by:
Hello all, I have received a dll from a reseller who sold me a data acquisition equipment and I am trying to use functions from the dll file but I am receiving an uncontrolled exception. ...
4
by: sam1967 | last post by:
How do I get a function to return a GMP integer type mpz_t when i try it i get an error message. i am trying mpz_t hooch (int x) { mpz_t y; ........
3
by: bxstylez | last post by:
rewrite this program (sum,average) using functions, possibly arrays? #include<stdlib.h> #include<stdio.h> main() { FILE *finpt, *foutpt;
1
by: Nathan Sokalski | last post by:
I have a Visual Studio Solution that contains multiple ASP.NET Projects. I do not want to put all of the pages (*.aspx files) in the root directory of my site, because that would be very...
1
by: gdarian216 | last post by:
I am reading in different names and scores from a file. I have created a struct that is made up of arrays and a string. Im tring to but the string and scores in the correct array by using a function....
3
by: Manikandan | last post by:
Hi, I'm copying projects from a solution in the vss. In my local system i created solution ,added that project(make modification related to solution) When i added this solution to vss, projects...
1
by: pcatton | last post by:
I have the situation where I have a lot of large databases that use a lot of the same functions. These prove very difficult to maintain and so I was wondering if anyone knew if it is possible to...
3
by: TamaThps | last post by:
I have to write a program that lets the user play the game of Craps. As of right now it is incomplete and I have run into some errors. It's my first time using functions instead of the program all...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.