473,421 Members | 1,666 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,421 software developers and data experts.

Calling functions from files

Hi,
I want to make a project that calls and executes a function (VB code) made
in a seperate file in the Application Folder. I know I can create the
function in my project and call it internally, but I want to put the
function's code in an external file, so that future updates to the function
will require a replacing the function file instead of re-installing the whole
project.

Can you give me ideas on how I can make small updates to my application
project without uninstalling and then re-installing the whole project?

Thanks,
Amjad
Nov 21 '05 #1
6 1685
Make two projects. One that is a class library project. This will compile
to a dll. The other your executable. You can then reference these function
in your project and when you want to update the dll you can.

Chris
"Amjad" <Am***@discussions.microsoft.com> wrote in message
news:89**********************************@microsof t.com...
Hi,
I want to make a project that calls and executes a function (VB code) made
in a seperate file in the Application Folder. I know I can create the
function in my project and call it internally, but I want to put the
function's code in an external file, so that future updates to the
function
will require a replacing the function file instead of re-installing the
whole
project.

Can you give me ideas on how I can make small updates to my application
project without uninstalling and then re-installing the whole project?

Thanks,
Amjad

Nov 21 '05 #2
Thanks for the idea.

- In order for the project to compile to a DLL, do I just include the
function's code in a module only? How do I make DLL files?
- Assuming that I made the DLL file. Can you give me an example on calling a
DLL file in my project?

Amjad

"Chris, Master of All Things Insignifican" wrote:
Make two projects. One that is a class library project. This will compile
to a dll. The other your executable. You can then reference these function
in your project and when you want to update the dll you can.

Chris
"Amjad" <Am***@discussions.microsoft.com> wrote in message
news:89**********************************@microsof t.com...
Hi,
I want to make a project that calls and executes a function (VB code) made
in a seperate file in the Application Folder. I know I can create the
function in my project and call it internally, but I want to put the
function's code in an external file, so that future updates to the
function
will require a replacing the function file instead of re-installing the
whole
project.

Can you give me ideas on how I can make small updates to my application
project without uninstalling and then re-installing the whole project?

Thanks,
Amjad


Nov 21 '05 #3
To make the dll, open a new project. Instead of calling it a type "Windows
Application", make a Class Library instead. The easiest way to do this is
to make add a second project in the same solution.

All of the classes you use right now are dlls. System.Windows.Forms.Form
which is what inherit when you make a form for your windows application is
just a dll with the namespace of System.Windows.Forms. So when you make
your dll you can just reference by its name. For example.

In the second project which is a class library make a new class:

'Not Tested!
Public Class MathFunction

'This is shared so I don't have to make an instance of the class
Public Shared Function SquareNumber(Value as Integer) as Long
return Value * Value
End Sub

End Class

Now have your main form use it

Public Class MainForm
inherits Form

Private MainForm_Load(....) handles Me.Load
messagebox.Show(MathFunction.SquareNumber(5))
End Sub

End Class
That's the idea. Depending how you set things up you may have to reference
your new dll in your project. You also might want to give a namespace to
your class library. If they are in the same solution I don't think you'll
have any issues seeing you new class.

Chris
"Amjad" <Am***@discussions.microsoft.com> wrote in message
news:77**********************************@microsof t.com...
Thanks for the idea.

- In order for the project to compile to a DLL, do I just include the
function's code in a module only? How do I make DLL files?
- Assuming that I made the DLL file. Can you give me an example on calling
a
DLL file in my project?

Amjad

"Chris, Master of All Things Insignifican" wrote:
Make two projects. One that is a class library project. This will
compile
to a dll. The other your executable. You can then reference these
function
in your project and when you want to update the dll you can.

Chris
"Amjad" <Am***@discussions.microsoft.com> wrote in message
news:89**********************************@microsof t.com...
> Hi,
> I want to make a project that calls and executes a function (VB code)
> made
> in a seperate file in the Application Folder. I know I can create the
> function in my project and call it internally, but I want to put the
> function's code in an external file, so that future updates to the
> function
> will require a replacing the function file instead of re-installing the
> whole
> project.
>
> Can you give me ideas on how I can make small updates to my application
> project without uninstalling and then re-installing the whole project?
>
> Thanks,
> Amjad


Nov 21 '05 #4
Just so you are aware (in case you don't see it)... the project type "Class
Library" is not available for all versions of VB.NET.

(There are work arounds).

Greg

"Chris, Master of All Things Insignificant" <chris@No_Spam_Please.com> wrote
in message news:OG**************@TK2MSFTNGP14.phx.gbl...
To make the dll, open a new project. Instead of calling it a type
"Windows Application", make a Class Library instead. The easiest way to
do this is to make add a second project in the same solution.

All of the classes you use right now are dlls. System.Windows.Forms.Form
which is what inherit when you make a form for your windows application is
just a dll with the namespace of System.Windows.Forms. So when you make
your dll you can just reference by its name. For example.

In the second project which is a class library make a new class:

'Not Tested!
Public Class MathFunction

'This is shared so I don't have to make an instance of the class
Public Shared Function SquareNumber(Value as Integer) as Long
return Value * Value
End Sub

End Class

Now have your main form use it

Public Class MainForm
inherits Form

Private MainForm_Load(....) handles Me.Load
messagebox.Show(MathFunction.SquareNumber(5))
End Sub

End Class
That's the idea. Depending how you set things up you may have to
reference your new dll in your project. You also might want to give a
namespace to your class library. If they are in the same solution I don't
think you'll have any issues seeing you new class.

Chris
"Amjad" <Am***@discussions.microsoft.com> wrote in message
news:77**********************************@microsof t.com...
Thanks for the idea.

- In order for the project to compile to a DLL, do I just include the
function's code in a module only? How do I make DLL files?
- Assuming that I made the DLL file. Can you give me an example on
calling a
DLL file in my project?

Amjad

"Chris, Master of All Things Insignifican" wrote:
Make two projects. One that is a class library project. This will
compile
to a dll. The other your executable. You can then reference these
function
in your project and when you want to update the dll you can.

Chris
"Amjad" <Am***@discussions.microsoft.com> wrote in message
news:89**********************************@microsof t.com...
> Hi,
> I want to make a project that calls and executes a function (VB code)
> made
> in a seperate file in the Application Folder. I know I can create the
> function in my project and call it internally, but I want to put the
> function's code in an external file, so that future updates to the
> function
> will require a replacing the function file instead of re-installing
> the
> whole
> project.
>
> Can you give me ideas on how I can make small updates to my
> application
> project without uninstalling and then re-installing the whole project?
>
> Thanks,
> Amjad


Nov 21 '05 #5
Open the References folder in your solution explorer for the Windows Form
project. On the Projects tab select you Class Library.

From code in your Windows Form try this:

Dim i as integer = ClassLibrary1.MathFunction.SomeSharedMethod()

"ClassLibrary1" is the root namespace of your Class Library project (unless
you changed it).

Greg
"Amjad" <Am***@discussions.microsoft.com> wrote in message
news:85**********************************@microsof t.com...
Thanks for the reply.

That idea makes sense. I created a "Class Library" project and a "Windows
Form" project in the same solution, however I'm unable to reference the
DLL
class in the Windows Form (i.e. "Name 'MathFunction' is not declared" in
your
code). Can you lead me to some online examples or documentation on how to
do
this?

Amjad

"Chris, Master of All Things Insignifican" wrote:
To make the dll, open a new project. Instead of calling it a type
"Windows
Application", make a Class Library instead. The easiest way to do this
is
to make add a second project in the same solution.

All of the classes you use right now are dlls. System.Windows.Forms.Form
which is what inherit when you make a form for your windows application
is
just a dll with the namespace of System.Windows.Forms. So when you make
your dll you can just reference by its name. For example.

In the second project which is a class library make a new class:

'Not Tested!
Public Class MathFunction

'This is shared so I don't have to make an instance of the class
Public Shared Function SquareNumber(Value as Integer) as Long
return Value * Value
End Sub

End Class

Now have your main form use it

Public Class MainForm
inherits Form

Private MainForm_Load(....) handles Me.Load
messagebox.Show(MathFunction.SquareNumber(5))
End Sub

End Class
That's the idea. Depending how you set things up you may have to
reference
your new dll in your project. You also might want to give a namespace to
your class library. If they are in the same solution I don't think
you'll
have any issues seeing you new class.

Chris
"Amjad" <Am***@discussions.microsoft.com> wrote in message
news:77**********************************@microsof t.com...
> Thanks for the idea.
>
> - In order for the project to compile to a DLL, do I just include the
> function's code in a module only? How do I make DLL files?
> - Assuming that I made the DLL file. Can you give me an example on
> calling
> a
> DLL file in my project?
>
> Amjad
>
> "Chris, Master of All Things Insignifican" wrote:
>
>> Make two projects. One that is a class library project. This will
>> compile
>> to a dll. The other your executable. You can then reference these
>> function
>> in your project and when you want to update the dll you can.
>>
>> Chris
>>
>>
>> "Amjad" <Am***@discussions.microsoft.com> wrote in message
>> news:89**********************************@microsof t.com...
>> > Hi,
>> > I want to make a project that calls and executes a function (VB
>> > code)
>> > made
>> > in a seperate file in the Application Folder. I know I can create
>> > the
>> > function in my project and call it internally, but I want to put the
>> > function's code in an external file, so that future updates to the
>> > function
>> > will require a replacing the function file instead of re-installing
>> > the
>> > whole
>> > project.
>> >
>> > Can you give me ideas on how I can make small updates to my
>> > application
>> > project without uninstalling and then re-installing the whole
>> > project?
>> >
>> > Thanks,
>> > Amjad
>>
>>
>>


Nov 21 '05 #6
Thanks Greg.
I added my ClassLibrary1 to the References of my Windows Form project, and
now I can see the class and its methods within my windows form code.

That's what I was looking for.

Amjad

"Greg Burns" wrote:
Open the References folder in your solution explorer for the Windows Form
project. On the Projects tab select you Class Library.

From code in your Windows Form try this:

Dim i as integer = ClassLibrary1.MathFunction.SomeSharedMethod()

"ClassLibrary1" is the root namespace of your Class Library project (unless
you changed it).

Greg
"Amjad" <Am***@discussions.microsoft.com> wrote in message
news:85**********************************@microsof t.com...
Thanks for the reply.

That idea makes sense. I created a "Class Library" project and a "Windows
Form" project in the same solution, however I'm unable to reference the
DLL
class in the Windows Form (i.e. "Name 'MathFunction' is not declared" in
your
code). Can you lead me to some online examples or documentation on how to
do
this?

Amjad

"Chris, Master of All Things Insignifican" wrote:
To make the dll, open a new project. Instead of calling it a type
"Windows
Application", make a Class Library instead. The easiest way to do this
is
to make add a second project in the same solution.

All of the classes you use right now are dlls. System.Windows.Forms.Form
which is what inherit when you make a form for your windows application
is
just a dll with the namespace of System.Windows.Forms. So when you make
your dll you can just reference by its name. For example.

In the second project which is a class library make a new class:

'Not Tested!
Public Class MathFunction

'This is shared so I don't have to make an instance of the class
Public Shared Function SquareNumber(Value as Integer) as Long
return Value * Value
End Sub

End Class

Now have your main form use it

Public Class MainForm
inherits Form

Private MainForm_Load(....) handles Me.Load
messagebox.Show(MathFunction.SquareNumber(5))
End Sub

End Class
That's the idea. Depending how you set things up you may have to
reference
your new dll in your project. You also might want to give a namespace to
your class library. If they are in the same solution I don't think
you'll
have any issues seeing you new class.

Chris
"Amjad" <Am***@discussions.microsoft.com> wrote in message
news:77**********************************@microsof t.com...
> Thanks for the idea.
>
> - In order for the project to compile to a DLL, do I just include the
> function's code in a module only? How do I make DLL files?
> - Assuming that I made the DLL file. Can you give me an example on
> calling
> a
> DLL file in my project?
>
> Amjad
>
> "Chris, Master of All Things Insignifican" wrote:
>
>> Make two projects. One that is a class library project. This will
>> compile
>> to a dll. The other your executable. You can then reference these
>> function
>> in your project and when you want to update the dll you can.
>>
>> Chris
>>
>>
>> "Amjad" <Am***@discussions.microsoft.com> wrote in message
>> news:89**********************************@microsof t.com...
>> > Hi,
>> > I want to make a project that calls and executes a function (VB
>> > code)
>> > made
>> > in a seperate file in the Application Folder. I know I can create
>> > the
>> > function in my project and call it internally, but I want to put the
>> > function's code in an external file, so that future updates to the
>> > function
>> > will require a replacing the function file instead of re-installing
>> > the
>> > whole
>> > project.
>> >
>> > Can you give me ideas on how I can make small updates to my
>> > application
>> > project without uninstalling and then re-installing the whole
>> > project?
>> >
>> > Thanks,
>> > Amjad
>>
>>
>>


Nov 21 '05 #7

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

Similar topics

11
by: juglesh | last post by:
at one centraldomain.com, I have central.php, which consists of this: <?php function square($num) { return $num * $num; } ?> at outerdomain.com, I have test.php, which consists of this:...
7
by: Julia Briggs | last post by:
Hello World - I admit I'm new to javascript but I've tried for days to find a solution to my problem. Basically I have 3 unique javascript files that do different screen display events that I...
0
by: Denis | last post by:
Hello, I am working on a large business application written mostly with VC++ and MFC. What I'm trying to do is accessing my database with the existing functions in my c++ application using XML...
6
by: Charlie | last post by:
Ok, I have three files: calc.cpp, calc.h, and ui.cpp. I would like to call a function that is located in ui.cpp from main() in calc.cpp. Both files have calc.h included, but when I tried to...
5
by: Andrew Slade | last post by:
Hello, I am making calls from one compilation unit to functions in another by pointers and I get the warnings below from gcc on 2.4.x Debian Linux. The executable seems to work fine but the...
19
by: Deniz Bahar | last post by:
Hi, I would like to call one of my functions the exact name as an existing C library function (for example K&R2 exercises asks me to make an atof function). If I don't include the header with...
19
by: Ross A. Finlayson | last post by:
Hi, I hope you can help me understand the varargs facility. Say I am programming in ISO C including stdarg.h and I declare a function as so: void log_printf(const char* logfilename, const...
11
by: j23 | last post by:
I have library (static) testlib.cpp: #include <stdarg.h> void xxx(...) { char buf; va_list args; va_start(args, buf); va_end(args); }
2
by: Daniel Lidström | last post by:
I'm using a library called fyba. This library reads and writes files in a format called sosi. fyba uses the following code to determine if the calling process has own methods to handle errors,...
16
by: teju | last post by:
hi, i am trying 2 merge 2 projects into one project.One project is using c language and the other one is using c++ code. both are working very fine independently.But now i need to merge both...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
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...
0
tracyyun
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...
0
agi2029
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,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.