473,513 Members | 2,620 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Including files

Please tell me the best way to do this (I am still new to VB.NET and ASPX)
as this should very easy for anyone with any experience to answer.

In the code behind file (filename.aspx.vb), I import things that are
namespace imports in the main file (filename.aspx). These are from the core
set. I would also like to have a set of functions that I write and use in
many pages, so that I write them once and for all and be done with it
without having to copy them. The way I envision is to include a file that
contains these functions, but I don't know how to do that here and my
searching didn't turn up anything. Note: this in not for including in the
aspx file. It is for the VB file.

(Coming from php there are several commands that could be used eg include,
require and require_once). How do I do it in VB.NET? If it is more
complicated than that, please direct me to some code samples.

Shelly
Sep 24 '07 #1
7 1413
"Shelly" <sh************@asap-consult.comwrote in message
news:13*************@corp.supernews.com...
Please tell me the best way to do this (I am still new to VB.NET and ASPX)
as this should very easy for anyone with any experience to answer.

In the code behind file (filename.aspx.vb), I import things that are
namespace imports in the main file (filename.aspx). These are from the
core set. I would also like to have a set of functions that I write and
use in many pages, so that I write them once and for all and be done with
it without having to copy them. The way I envision is to include a file
that contains these functions, but I don't know how to do that here and my
searching didn't turn up anything. Note: this in not for including in the
aspx file. It is for the VB file.

(Coming from php there are several commands that could be used eg include,
require and require_once). How do I do it in VB.NET? If it is more
complicated than that, please direct me to some code samples.
1) Create a new class called MyFunctions

2) Create a new function e.g.

Public Shared MyFunction(MyString As String) As String

3) Then, anywhere else in your VB.NET code:

Dim MyString As String = MyFunctions.MyFunction("Hello")
I *think* the above is correct - I never go anywhere near VB.NET...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Sep 24 '07 #2

"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:Oh**************@TK2MSFTNGP02.phx.gbl...
"Shelly" <sh************@asap-consult.comwrote in message
news:13*************@corp.supernews.com...
>Please tell me the best way to do this (I am still new to VB.NET and
ASPX) as this should very easy for anyone with any experience to answer.

In the code behind file (filename.aspx.vb), I import things that are
namespace imports in the main file (filename.aspx). These are from the
core set. I would also like to have a set of functions that I write and
use in many pages, so that I write them once and for all and be done with
it without having to copy them. The way I envision is to include a file
that contains these functions, but I don't know how to do that here and
my searching didn't turn up anything. Note: this in not for including in
the aspx file. It is for the VB file.

(Coming from php there are several commands that could be used eg
include, require and require_once). How do I do it in VB.NET? If it is
more complicated than that, please direct me to some code samples.

1) Create a new class called MyFunctions

2) Create a new function e.g.

Public Shared MyFunction(MyString As String) As String

3) Then, anywhere else in your VB.NET code:

Dim MyString As String = MyFunctions.MyFunction("Hello")
I *think* the above is correct - I never go anywhere near VB.NET...
Thanks Mark, but that was not what I was asking. If that class is in some
file called MyFunctions.vb or Myfunctions.aspx.vb (or whatever extension it
should be), how to I include that file in my thisPage.aspx.vb?

It would be the same for c#. I don't know what the code-behind is for c#,
but I guess it is cs. If so, how would I include that MyFunctions.aspx.cs
or MyFunctions.cs (or whatever extension) into thisPage.aspx.cs?

Shelly
Sep 24 '07 #3
Please tell me the best way to do this (I am still new to VB.NET and
ASPX) as this should very easy for anyone with any experience to
answer.

In the code behind file (filename.aspx.vb), I import things that are
namespace imports in the main file (filename.aspx). These are from
the core set. I would also like to have a set of functions that I
write and use in many pages, so that I write them once and for all and
be done with it without having to copy them. The way I envision is to
include a file that contains these functions, but I don't know how to
do that here and my searching didn't turn up anything. Note: this in
not for including in the aspx file. It is for the VB file.

(Coming from php there are several commands that could be used eg
include, require and require_once). How do I do it in VB.NET? If it
is more complicated than that, please direct me to some code samples.

Shelly
You don't "include" files. Instead you build classes that you use from
within other classes.
If that library-class is in the same project (assembly) as the class
you want to use it from, you can just use it (you might want to use
the complete namespace-path at first).
If the class is in a different assembly, then the project you want to
use it from must have a "reference" to that assembly (right-click
the project, choose 'add reference').

Hans Kesting
Sep 24 '07 #4
"Shelly" <sh*******@asap-consult.comwrote in message
news:13*************@corp.supernews.com...
Thanks Mark, but that was not what I was asking. If that class is in some
file called MyFunctions.vb or Myfunctions.aspx.vb (or whatever extension
it should be), how to I include that file in my thisPage.aspx.vb?
You don't - you simply call the function from within your code.

Read me post again...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Sep 24 '07 #5

"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
"Shelly" <sh*******@asap-consult.comwrote in message
news:13*************@corp.supernews.com...
>Thanks Mark, but that was not what I was asking. If that class is in
some file called MyFunctions.vb or Myfunctions.aspx.vb (or whatever
extension it should be), how to I include that file in my
thisPage.aspx.vb?

You don't - you simply call the function from within your code.

Read me post again...
Let me get this straight. You include that class in some file, say
MyFunctions.vb and that file is in the project. Then. BEING IN THE PROJECT
is what makes it available to other files?

Shelly
Sep 24 '07 #6
"Shelly" <sh*******@asap-consult.comwrote in message
news:13*************@corp.supernews.com...
You include that class in some file, say MyFunctions.vb
Yes - you can have each class in its own code file, or you can include
several classes in the same code file - makes no difference whatsoever to
the compiler...
and that file is in the project.
Yes.
Then. BEING IN THE PROJECT is what makes it available to other files?
Er, the fact that it's in the same project... :-)

The Shared keyword before the function name means that it can be called
directly without requiring an instantiation of its class...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Sep 24 '07 #7
Thank you. (Yes, I meant the SAME project).

Shelly

"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
"Shelly" <sh*******@asap-consult.comwrote in message
news:13*************@corp.supernews.com...
>You include that class in some file, say MyFunctions.vb

Yes - you can have each class in its own code file, or you can include
several classes in the same code file - makes no difference whatsoever to
the compiler...
>and that file is in the project.

Yes.
>Then. BEING IN THE PROJECT is what makes it available to other files?

Er, the fact that it's in the same project... :-)

The Shared keyword before the function name means that it can be called
directly without requiring an instantiation of its class...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Sep 24 '07 #8

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

Similar topics

4
1810
by: WindAndWaves | last post by:
Hi Gurus I hope I am going to make sense with this question: I have an html page that I have turned into a php page with a bit of php code above the html (connect to database, massage data a little, mix with html, etc...). Now, I would like to use a function in my php code, as otherwise I have to type the same thing over and over again....
3
1784
by: Sean Quinn | last post by:
Hi, I don't know if anyone has run into similar problems, but it seems like when I use `require_once(...)' with files that contain functions I get an error indicating that it can't redeclare the functions. I thought the point of the once directive was to PREVENT the system from including duplicate files (and thus attempting to redeclare...
5
5663
by: mayamorning123 | last post by:
A comparison among six VSS remote tools including SourceOffSite , SourceAnyWhere, VSS Connect, SourceXT, VSS Remoting, VSS.NET To view the full article, please visit http://www.BetterVssRemoting.com Better VSS Remote Access Tool This article makes a detailed comparison among SourceAnyWhere 4.0, SourceOffSite 4.1, VSS Connect 1.5,...
0
3271
by: bettervssremoting | last post by:
To view the full article, please visit http://www.BetterVssRemoting.com Better VSS Remote Access Tool including SourceOffSite, SourceAnyWhere and VSS Remoting This article makes a detailed comparison among SourceAnyWhere, SourceOffSite, VSS Remoting and possible others.
1
1085
by: Ben | last post by:
Hi guys, this *should* be a simple problem, but I've never really got my head around it. I'm hoping somebody on this message board could help me out? I don't really have any experience with VS.NET, which is probably why I'm having so much trouble! Basically, I've been doing some OpenGL coding using VS.NET as the compiler. Obviously (if you...
8
3033
by: nrhayyal | last post by:
Hi c++ Gurus, Need your blessing. while testing few aspects with respect to header file inclusions, i observed few things which i would like to share with you. i have a file sqlca.h in which a structure sqlca is declared. i included this file as a soft link in /usr/include. the soft link is as follows: sqlca.h ->...
31
3563
by: Joseph Wakeling | last post by:
Hello all, I'm writing some programs that will be using modules from the GNU Scientific Library (GSL). Include commands within the GSL modules have commands such as, #include <gsl/gsl_rng.h> (for example). Yet these header files aren't actually in the gsl
18
2836
by: sam_cit | last post by:
Hi Everyone, int main() { printf("not included stdio.h"); } Yes, i haven't included stdio.h and my compiler would generate a warning and would assume that it would return a int, my question is how does the linker manage to link the function invocation to the proper
10
1639
by: Ben Sehara | last post by:
Hi, I want to include three php files in index.php file like the code below. But it always shows up only two, any two of the three, any order. <tr> <td><?php include ("includes/documents.php"); ?>&nbsp;</td> </tr> <tr> <td><?php include ("includes/locations.php"); ?>&nbsp;</td>
3
2562
by: KIRAN | last post by:
Hello all, My question is about the way of including header files(*.h) in source files (*.c) I have three folders, -build ( for project makefiles) -include ( for *.h files) -src (for *.c files). I know that there are two ways of specifying include path of header files
0
7397
Oralloy
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. ...
1
7125
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...
0
7543
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 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...
1
5102
isladogs
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...
0
4757
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3239
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1612
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
1
813
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
470
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.