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

How to create a function

Hello,

I am working on an Asp.Net 2.0.
I created a master page named "MyMasterPage.master".
I created the function "SUM" in my master page VB code.

I then created the page "MyPage.aspx" from my master page.
When I try to use the function "SUM" in "MyPage" VB code it says:
- Name "SUM" is not declared.

I created the SUM function in different ways:
- "SUB SUM()..."
- "Private SUB SUM()..."
- "Public SUB SUM()..." > I thought this would solve the problem.

Basically I need to create functions which will be accessible from many
Aspx pages.

Thank You Very Much,
Miguel

Jan 20 '06 #1
5 1381
Lo,

In VB.NET

1. Create new module called i.e. MyUtilityFunctions and add code
public function Sum(byval a as integer, byval b as integer) as Integer
return a + b
end function
You can use it in your code as follows
dim result as integer = MyUtilityFunctions.Sum(1, 2)

or.
2. Create new class called i.e. MyUtilityFunctions and add code
public shared function Sum(byval a as integer, byval b as integer) as
Integer
return a + b
end function

and you can use it in your code:
dim result as integer = MyUtilityFunctions.Sum(1, 2)

I advise to read a VB.NET tutorial/book to gain basic knowledge about vb.net.
--
Milosz Skalecki
MCP, MCAD
"Miguel Dias Moura" wrote:
Hello,

I am working on an Asp.Net 2.0.
I created a master page named "MyMasterPage.master".
I created the function "SUM" in my master page VB code.

I then created the page "MyPage.aspx" from my master page.
When I try to use the function "SUM" in "MyPage" VB code it says:
- Name "SUM" is not declared.

I created the SUM function in different ways:
- "SUB SUM()..."
- "Private SUB SUM()..."
- "Public SUB SUM()..." > I thought this would solve the problem.

Basically I need to create functions which will be accessible from many
Aspx pages.

Thank You Very Much,
Miguel

Jan 20 '06 #2
In your page, specifying the @masterType directive..

<%@ Page .... %>
<%@ MasterType VirtualPath="~/master/Main.master" %>
then from your codebehind you should be able to do:
Master.Sum(...)

declare sum as

public sub Sum
end sub

--
http://www.openmymind.net/

"Miguel Dias Moura" <md*REMOVE*moura@gmail*NOSPAM*.com> wrote in message
news:ua**************@TK2MSFTNGP15.phx.gbl...
Hello,

I am working on an Asp.Net 2.0.
I created a master page named "MyMasterPage.master".
I created the function "SUM" in my master page VB code.

I then created the page "MyPage.aspx" from my master page.
When I try to use the function "SUM" in "MyPage" VB code it says:
- Name "SUM" is not declared.

I created the SUM function in different ways:
- "SUB SUM()..."
- "Private SUB SUM()..."
- "Public SUB SUM()..." > I thought this would solve the problem.

Basically I need to create functions which will be accessible from many
Aspx pages.

Thank You Very Much,
Miguel

Jan 20 '06 #3
I agree that a separate utility class is the way to go assuming it doesn't
actually interact with the master page.

Say you wanted Sum to do:

Sub Sum (byval x as string)
myHeaderText.Text = x
end sub

where myHeaderText is a label on the master page, then you'd want to keep
Sum on the master page.

Karl

--
http://www.openmymind.net/

"Milosz Skalecki" <mi*****@REMOVEITwp.pl> wrote in message
news:A8**********************************@microsof t.com...
Lo,

In VB.NET

1. Create new module called i.e. MyUtilityFunctions and add code
public function Sum(byval a as integer, byval b as integer) as Integer
return a + b
end function
You can use it in your code as follows
dim result as integer = MyUtilityFunctions.Sum(1, 2)

or.
2. Create new class called i.e. MyUtilityFunctions and add code
public shared function Sum(byval a as integer, byval b as integer)
as
Integer
return a + b
end function

and you can use it in your code:
dim result as integer = MyUtilityFunctions.Sum(1, 2)

I advise to read a VB.NET tutorial/book to gain basic knowledge about
vb.net.
--
Milosz Skalecki
MCP, MCAD
"Miguel Dias Moura" wrote:
Hello,

I am working on an Asp.Net 2.0.
I created a master page named "MyMasterPage.master".
I created the function "SUM" in my master page VB code.

I then created the page "MyPage.aspx" from my master page.
When I try to use the function "SUM" in "MyPage" VB code it says:
- Name "SUM" is not declared.

I created the SUM function in different ways:
- "SUB SUM()..."
- "Private SUB SUM()..."
- "Public SUB SUM()..." > I thought this would solve the problem.

Basically I need to create functions which will be accessible from many
Aspx pages.

Thank You Very Much,
Miguel

Jan 20 '06 #4
Agree, i thought He wanted just a utility independent function that does't
interact with master page.
--
Milosz Skalecki
MCP, MCAD
"Karl Seguin [MVP]" wrote:
I agree that a separate utility class is the way to go assuming it doesn't
actually interact with the master page.

Say you wanted Sum to do:

Sub Sum (byval x as string)
myHeaderText.Text = x
end sub

where myHeaderText is a label on the master page, then you'd want to keep
Sum on the master page.

Karl

--
http://www.openmymind.net/

"Milosz Skalecki" <mi*****@REMOVEITwp.pl> wrote in message
news:A8**********************************@microsof t.com...
Lo,

In VB.NET

1. Create new module called i.e. MyUtilityFunctions and add code
public function Sum(byval a as integer, byval b as integer) as Integer
return a + b
end function
You can use it in your code as follows
dim result as integer = MyUtilityFunctions.Sum(1, 2)

or.
2. Create new class called i.e. MyUtilityFunctions and add code
public shared function Sum(byval a as integer, byval b as integer)
as
Integer
return a + b
end function

and you can use it in your code:
dim result as integer = MyUtilityFunctions.Sum(1, 2)

I advise to read a VB.NET tutorial/book to gain basic knowledge about
vb.net.
--
Milosz Skalecki
MCP, MCAD
"Miguel Dias Moura" wrote:
Hello,

I am working on an Asp.Net 2.0.
I created a master page named "MyMasterPage.master".
I created the function "SUM" in my master page VB code.

I then created the page "MyPage.aspx" from my master page.
When I try to use the function "SUM" in "MyPage" VB code it says:
- Name "SUM" is not declared.

I created the SUM function in different ways:
- "SUB SUM()..."
- "Private SUB SUM()..."
- "Public SUB SUM()..." > I thought this would solve the problem.

Basically I need to create functions which will be accessible from many
Aspx pages.

Thank You Very Much,
Miguel


Jan 20 '06 #5
ya, probably :) it wasn't clear

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Milosz Skalecki" <mi*****@REMOVEITwp.pl> wrote in message
news:FC**********************************@microsof t.com...
Agree, i thought He wanted just a utility independent function that does't
interact with master page.
--
Milosz Skalecki
MCP, MCAD
"Karl Seguin [MVP]" wrote:
I agree that a separate utility class is the way to go assuming it
doesn't
actually interact with the master page.

Say you wanted Sum to do:

Sub Sum (byval x as string)
myHeaderText.Text = x
end sub

where myHeaderText is a label on the master page, then you'd want to keep
Sum on the master page.

Karl

--
http://www.openmymind.net/

"Milosz Skalecki" <mi*****@REMOVEITwp.pl> wrote in message
news:A8**********************************@microsof t.com...
> Lo,
>
> In VB.NET
>
> 1. Create new module called i.e. MyUtilityFunctions and add code
> public function Sum(byval a as integer, byval b as integer) as
> Integer
> return a + b
> end function
> You can use it in your code as follows
> dim result as integer = MyUtilityFunctions.Sum(1, 2)
>
> or.
> 2. Create new class called i.e. MyUtilityFunctions and add code
> public shared function Sum(byval a as integer, byval b as
> integer)
> as
> Integer
> return a + b
> end function
>
> and you can use it in your code:
> dim result as integer = MyUtilityFunctions.Sum(1, 2)
>
> I advise to read a VB.NET tutorial/book to gain basic knowledge about
> vb.net.
> --
> Milosz Skalecki
> MCP, MCAD
>
>
> "Miguel Dias Moura" wrote:
>
>> Hello,
>>
>> I am working on an Asp.Net 2.0.
>> I created a master page named "MyMasterPage.master".
>> I created the function "SUM" in my master page VB code.
>>
>> I then created the page "MyPage.aspx" from my master page.
>> When I try to use the function "SUM" in "MyPage" VB code it says:
>> - Name "SUM" is not declared.
>>
>> I created the SUM function in different ways:
>> - "SUB SUM()..."
>> - "Private SUB SUM()..."
>> - "Public SUB SUM()..." > I thought this would solve the problem.
>>
>> Basically I need to create functions which will be accessible from
>> many
>> Aspx pages.
>>
>> Thank You Very Much,
>> Miguel
>>
>>


Jan 20 '06 #6

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

Similar topics

6
by: Rajesh N Thipse | last post by:
Hi, Files can be created using _creat. Similarly, is there a function to create a directory? ~Rajesh
1
by: Barbara Lindsey | last post by:
I am a postgres newbie. I am trying to create a trigger that will put a copy of a record into a backup table before update or delete. As I understand it, in order to do this I must have a...
4
by: Alex Page | last post by:
This is probably really basic, but I can't seem to get it to work. I'm trying to create an enumerated type, using the following code: CREATE FUNCTION enum_gender_in (cstring) RETURNS enum_gender...
7
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I...
18
by: Steven Bethard | last post by:
I've updated the PEP based on a number of comments on comp.lang.python. The most updated versions are still at: http://ucsu.colorado.edu/~bethard/py/pep_create_statement.txt...
14
by: mistral | last post by:
Need php script to create mySQL database programmatically; since hosting configuration may not allow create database from script, script also need eliminate/rewrite all restrictions in appropriate...
4
by: etuncer | last post by:
Hello All, I have Access 2003, and am trying to build a database for my small company. I want to be able to create a word document based on the data entered through a form. the real question is...
10
by: SM | last post by:
Hello I'm trying to create a multi dimensional array in JavaScript, but after some reading i still can't figure out how to apply it to my model. Here it is: I have a list A and for each item...
4
by: Vlad | last post by:
I am having problems using the file.create method within a function that is called when looping through an array of filepaths. If I call my function with a hardcoded file path --C:\Temp.txt the...
0
by: TrevRex | last post by:
Hello, I work for a non-profit in San Diego as a GIS Specialist. I have had to teach myself about some scripting to create some dynamic maps, but I am still very limited in my skills, so I have...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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
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...

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.