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 10 1401
"Anil Gupte" <an*******@icin ema.comwrote in message
news:OG******** ******@TK2MSFTN GP05.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.
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
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.c omschreef in bericht
news:eF******** ******@TK2MSFTN GP04.phx.gbl...
>
"Anil Gupte" <an*******@icin ema.comwrote in message
news:OG******** ******@TK2MSFTN GP05.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.
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
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*********@co mcast.netschree f in bericht
news:24******** *************** ***********@l6g 2000prm.googleg roups.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
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.c omwrote in message
news:eF******** ******@TK2MSFTN GP04.phx.gbl...
>
"Anil Gupte" <an*******@icin ema.comwrote in message
news:OG******** ******@TK2MSFTN GP05.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.
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******** *************** ***********@mic rosoft.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
"Anil Gupte" <an*******@icin ema.comwrote in message
news:%2******** ********@TK2MSF TNGP04.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.
"Anil Gupte" <an*******@icin ema.comwrote in message
news:eY******** ******@TK2MSFTN GP04.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+Clas s+Library+proje ct+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. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 charcters in it, that the code needs to run until all
bad characters are gone? For example, if a file has the name
"<bad*mac\file" the program has to run 3 times to get all three bad
chars out of the file name.
The passes look like this:
|
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.
Please are there anyone who can show me which are the
steps to use functions from a dll file?. Also, are there
differents dll files?, and are there more than one method
|
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;
........
|
by: bxstylez |
last post by:
rewrite this program (sum,average) using functions, possibly arrays?
#include<stdlib.h>
#include<stdio.h>
main()
{
FILE *finpt,
*foutpt;
|
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 disorganized. However, I am having
trouble getting any projects other than the one that I place in the root
directory to work. What extra steps do I need to take to place a project in
a directory other than the root? I am using a webhosting service...
| |
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. I am having trouble and im stuck if anyone can provide some insight I would appreciate it.
this is what i have so far.....
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
|
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 are referred to the
original solution not from my new solution
I will explain more clearly
i have project folder in vss(v4.5)
v4.5(folder)
project1(project)
|
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 use external
database functions. I know this is possible in the VBA code using
references and whilst this is good what I would really like to be able
to do is use external functions in queries as well. The only way I
have found of doing this is to...
|
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 being in the int main().
I am using visual studio on windows XP.
In my code I've defined a local variable in a function but when I run the program and it gets to that function it says I have an undeclared variable.
The code for the program...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |