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

Name 'x' is not declared question

pb
Hi,

I have built a page with some generic functions in the code behind -
all works fine.

I then wanted to put these functions in their own code modules, so in
the app_code folder I created class1.vb with the content such as...

------------------------------------------------
Imports Microsoft.VisualBasic

Public Class Class1

Public Function xx() As Boolean
xx = True
End Function

End Class
----------------------------------------

Now in the code behind page, from where this function is called, I get
the error message "name 'xx' is not declared"

I've read the documentation as far as I can fugure out, this should
work. I would sure appreciate if anyone can tell me what I am missing.

Thanks,

Pb

Jun 4 '07 #1
3 2061
pb
On Jun 5, 8:53 am, pb <philbrier...@hotmail.comwrote:
Hi,

I have built a page with some generic functions in the code behind -
all works fine.

I then wanted to put these functions in their own code modules, so in
the app_code folder I created class1.vb with the content such as...

------------------------------------------------
Imports Microsoft.VisualBasic

Public Class Class1

Public Function xx() As Boolean
xx = True
End Function

End Class
----------------------------------------

Now in the code behind page, from where this function is called, I get
the error message "name 'xx' is not declared"

I've read the documentation as far as I can fugure out, this should
work. I would sure appreciate if anyone can tell me what I am missing.

Thanks,

Pb
I've figured out that if I change the inherits bit at the top of the
code behind page it now sees the function, but a load of other errors
now occur. How do I make class1 visible to system.web.UI.Page?

'Inherits System.Web.UI.Page
Inherits class1

Jun 4 '07 #2
pb
On Jun 5, 9:15 am, pb <philbrier...@hotmail.comwrote:
On Jun 5, 8:53 am, pb <philbrier...@hotmail.comwrote:


Hi,
I have built a page with some generic functions in the code behind -
all works fine.
I then wanted to put these functions in their own code modules, so in
the app_code folder I created class1.vb with the content such as...
------------------------------------------------
Imports Microsoft.VisualBasic
Public Class Class1
Public Function xx() As Boolean
xx = True
End Function
End Class
----------------------------------------
Now in the code behind page, from where this function is called, I get
the error message "name 'xx' is not declared"
I've read the documentation as far as I can fugure out, this should
work. I would sure appreciate if anyone can tell me what I am missing.
Thanks,
Pb

I've figured out that if I change the inherits bit at the top of the
code behind page it now sees the function, but a load of other errors
now occur. How do I make class1 visible to system.web.UI.Page?

'Inherits System.Web.UI.Page
Inherits class1- Hide quoted text -

- Show quoted text -
OK - figured it out. Trawling this group came up with a lot of people
asking the same question but few simple answers, so here it is...

In code behind file you have to put

Dim MyCommonFunctions As New class1
and the use like

y = MyCommonFunctions.xx

;-)

Jun 5 '07 #3
pb wrote:
On Jun 5, 9:15 am, pb <philbrier...@hotmail.comwrote:
>On Jun 5, 8:53 am, pb <philbrier...@hotmail.comwrote:


>>Hi,
I have built a page with some generic functions in the code behind -
all works fine.
I then wanted to put these functions in their own code modules, so in
the app_code folder I created class1.vb with the content such as...
------------------------------------------------
Imports Microsoft.VisualBasic
Public Class Class1
Public Function xx() As Boolean
xx = True
End Function
End Class
----------------------------------------
Now in the code behind page, from where this function is called, I get
the error message "name 'xx' is not declared"
I've read the documentation as far as I can fugure out, this should
work. I would sure appreciate if anyone can tell me what I am missing.
Thanks,
Pb
I've figured out that if I change the inherits bit at the top of the
code behind page it now sees the function, but a load of other errors
now occur. How do I make class1 visible to system.web.UI.Page?

'Inherits System.Web.UI.Page
Inherits class1- Hide quoted text -

- Show quoted text -

OK - figured it out. Trawling this group came up with a lot of people
asking the same question but few simple answers, so here it is...

In code behind file you have to put

Dim MyCommonFunctions As New class1
and the use like

y = MyCommonFunctions.xx

;-)
If your method doesn't use any data from it's class, you should make it
static (Shared in VB):

Public Shared Function xx() As Boolean
xx = True
End Function

For static methods you don't need to create an instance of the class to
use them, just specify the class name and the method name:

y = Class1.xx

--
Göran Andersson
_____
http://www.guffa.com
Jun 5 '07 #4

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

Similar topics

4
by: Dan Jacobson | last post by:
Using <A name="x_y-z"></A>, I even get nervous about the _ and -. w3-recs/RECS/html4/struct/links.html seems to say all of ascii is cool and beyond. Anyway, just what is the safe range for...
8
by: Andrew McNab | last post by:
Hi folks, I have a problem with an MS Access SQL query which is being used in an Access Report, and am wondering if anyone can help. Basically, my query (shown below) gets some records from a...
13
by: Don | last post by:
How do I get an Enum's type using only the Enum name? e.g. Dim enumType as System.Type Dim enumName as String = "MyEnum" enumType = ???(enumName)
3
by: marylipscomb | last post by:
I have a question about my asp.net application. It tells me that Name 'lblMessage' is not declared. Description: An error occurred during the compilation of a resource required to service this...
4
by: andrew | last post by:
Hi, I have routinely added anchors to pages using both name and id: <a name="example" id="example"></a> under the possibly mistaken assumption that at some stage "name" might be deprecated...
6
by: rdstevenson | last post by:
Hi, Something I've never come across before and has given me a headache. I have a txt file with content similar to below I want to read in each line do a split on the = and then create a...
15
by: TonyV | last post by:
Hey all, for debugging purposes, I'd like to be able to access an object's instance name from within the object class. For example, I'd like to be able to do something like this: ...
2
by: developer.new | last post by:
Hi I have a question regarding this concept I learned about recently: Name Hiding. Here's what I've come across: There is a base class with two functions with the same name but different...
0
by: padmagvs | last post by:
I have a wsdl something like this <?xml version="1.0" ?> <definitions targetNamespace="http://abc.com/namespace/wsif/samples/abc" xmlns:tns="http://abc.com/namespace/wsif/samples/abc"...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: 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...

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.