473,466 Members | 1,307 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Very Confused: Class, Imports, ...

Hello,

I am working in a web site where all the code is placed in aspx.vb
files.
After a while I realized that many functions included in my aspx.vb
files where common to all pages.

I created a new file named common.vb where I created a class named
common and where I place all common functions:

Imports System

Public Class Common
Public Shared Sub MyFunction01()
...
End Sub
...
End Class

In my aspx.vb file I have:

Imports Common

Public Class myPage

Inherits System.Web.UI.Page
Private Sub Page_Load(
MyFunction01()
End Sub

This is all I have. I get the error:
Namespace or Type 'common' for the Imports 'common' cannot be found.

Basically all I need is to use Common functions in my aspx pages class.

Can someone tell me specifically what am I doing wrong?

Thanks,
Miguel
Nov 19 '05 #1
5 1322
Imports Namespace, or using Namespace in c#, is just a shortcut. You don’t
have to use it. For example, in following code
Dim dap As System.Data.SqlClient.SqlDataAdapter

If you use Imports System.Data.SqlClient, you can write it in short

Dim dap As SqlDataAdapter

In your case, the Common is a class rather than a Namespace. You cannot use
Imports Common.
HTH

Elton Wang
el********@hotmail.com
"Shapper" wrote:
Hello,

I am working in a web site where all the code is placed in aspx.vb
files.
After a while I realized that many functions included in my aspx.vb
files where common to all pages.

I created a new file named common.vb where I created a class named
common and where I place all common functions:

Imports System

Public Class Common
Public Shared Sub MyFunction01()
...
End Sub
...
End Class

In my aspx.vb file I have:

Imports Common

Public Class myPage

Inherits System.Web.UI.Page
Private Sub Page_Load(
MyFunction01()
End Sub

This is all I have. I get the error:
Namespace or Type 'common' for the Imports 'common' cannot be found.

Basically all I need is to use Common functions in my aspx pages class.

Can someone tell me specifically what am I doing wrong?

Thanks,
Miguel

Nov 19 '05 #2
Shapper,

what you need to do is compile common.vb to common.dll using the
command-line compiler (vbc.exe) and reference *that* in your VS.NET project.

vbc /t:library /out:common.dll common.vb

If you need to import .Net classes, include them in your command line:
vbc /t:library /r:system.dll /r:system.web.dll /out:common.dll common.vb

Once your assembly ( common.dll ) is compiled,
place it in the /bin directory of your application
and you will be able to call any of its functions.


Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================

"Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hello,

I am working in a web site where all the code is placed in aspx.vb files.
After a while I realized that many functions included in my aspx.vb files where common
to all pages.

I created a new file named common.vb where I created a class named common and where I
place all common functions:

Imports System

Public Class Common
Public Shared Sub MyFunction01()
...
End Sub
... End Class

In my aspx.vb file I have:

Imports Common

Public Class myPage

Inherits System.Web.UI.Page
Private Sub Page_Load(
MyFunction01()
End Sub

This is all I have. I get the error:
Namespace or Type 'common' for the Imports 'common' cannot be found.

Basically all I need is to use Common functions in my aspx pages class.

Can someone tell me specifically what am I doing wrong?

Thanks,
Miguel

Nov 19 '05 #3
Hello,

So compiling it is the only way?
Isn't it possible to make this work without compiling the common.vb?

Thanks,
Miguel

"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:no***********@nowhere.com:
Shapper,

what you need to do is compile common.vb to common.dll using the
command-line compiler (vbc.exe) and reference *that* in your VS.NET project.

vbc /t:library /out:common.dll common.vb

If you need to import .Net classes, include them in your command line:
vbc /t:library /r:system.dll /r:system.web.dll /out:common.dll common.vb

Once your assembly ( common.dll ) is compiled,
place it in the /bin directory of your application
and you will be able to call any of its functions.


Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================

"Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hello,

I am working in a web site where all the code is placed in aspx.vb files.
After a while I realized that many functions included in my aspx.vb files where common
to all pages.

I created a new file named common.vb where I created a class named common and where I
place all common functions:

Imports System

Public Class Common
Public Shared Sub MyFunction01()
...
End Sub
... End Class

In my aspx.vb file I have:

Imports Common

Public Class myPage

Inherits System.Web.UI.Page
Private Sub Page_Load(
MyFunction01()
End Sub

This is all I have. I get the error:
Namespace or Type 'common' for the Imports 'common' cannot be found.

Basically all I need is to use Common functions in my aspx pages class.

Can someone tell me specifically what am I doing wrong?

Thanks,
Miguel


Nov 19 '05 #4
Hello Juan,

I use Web Matrix because I feel it's simpler and faster to develop.
I also have Visual Studio 2003. Is it possible to use the command-line
compiler without needing to install Visual Studio?

Thanks,
Miguel

"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:no***********@nowhere.com:
Shapper,

what you need to do is compile common.vb to common.dll using the
command-line compiler (vbc.exe) and reference *that* in your VS.NET project.

vbc /t:library /out:common.dll common.vb

If you need to import .Net classes, include them in your command line:
vbc /t:library /r:system.dll /r:system.web.dll /out:common.dll common.vb

Once your assembly ( common.dll ) is compiled,
place it in the /bin directory of your application
and you will be able to call any of its functions.


Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================

"Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hello,

I am working in a web site where all the code is placed in aspx.vb files.
After a while I realized that many functions included in my aspx.vb files where common
to all pages.

I created a new file named common.vb where I created a class named common and where I
place all common functions:

Imports System

Public Class Common
Public Shared Sub MyFunction01()
...
End Sub
... End Class

In my aspx.vb file I have:

Imports Common

Public Class myPage

Inherits System.Web.UI.Page
Private Sub Page_Load(
MyFunction01()
End Sub

This is all I have. I get the error:
Namespace or Type 'common' for the Imports 'common' cannot be found.

Basically all I need is to use Common functions in my aspx pages class.

Can someone tell me specifically what am I doing wrong?

Thanks,
Miguel


Nov 19 '05 #5
Sure, Miguel, you can do that without either.

Just open a command window ( cmd.exe );
make sure that the .Net Framework directory is in your path
( the .Net dir is where the compilers are located (vbc.exe, csc.exe));
navigate to the directory where you have your .vb files,
and run the compile command :

vbc /t:library /out:common.dll common.vb

If you need to import .Net classes, include them in your command line:
vbc /t:library /r:system.dll /r:system.web.dll /out:common.dll common.vb

common.dll will be created/compiled in the current directory.

Move it to the /bin directory of your application and fire away.
If you want to have VS.NET use it, reference it in your project.

Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================

"Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*com> wrote in message
news:u$**************@TK2MSFTNGP09.phx.gbl...
Hello Juan,

I use Web Matrix because I feel it's simpler and faster to develop.
I also have Visual Studio 2003. Is it possible to use the command-line compiler without
needing to install Visual Studio?

Thanks,
Miguel

"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:no***********@nowhere.com:
Shapper,

what you need to do is compile common.vb to common.dll using the
command-line compiler (vbc.exe) and reference *that* in your VS.NET project.

vbc /t:library /out:common.dll common.vb

If you need to import .Net classes, include them in your command line:
vbc /t:library /r:system.dll /r:system.web.dll /out:common.dll common.vb

Once your assembly ( common.dll ) is compiled,
place it in the /bin directory of your application
and you will be able to call any of its functions.


Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================

"Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
> Hello,
>
> I am working in a web site where all the code is placed in aspx.vb files.
> After a while I realized that many functions included in my aspx.vb files where
> common
> to all pages.
>
> I created a new file named common.vb where I created a class named common and where I
> place all common functions:
>
> Imports System
>
> Public Class Common
> Public Shared Sub MyFunction01()
> ...
> End Sub
> ... End Class
>
> In my aspx.vb file I have:
>
> Imports Common
>
> Public Class myPage
>
> Inherits System.Web.UI.Page
> Private Sub Page_Load(
> MyFunction01()
> End Sub
>
> This is all I have. I get the error:
> Namespace or Type 'common' for the Imports 'common' cannot be found.
>
> Basically all I need is to use Common functions in my aspx pages class.
>
> Can someone tell me specifically what am I doing wrong?
>
> Thanks,
> Miguel
>
>

Nov 19 '05 #6

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

Similar topics

3
by: Richard | last post by:
I have a requirement to put a GDI style circle or rectangle border around the selected row of a datagrid/ It will overlap into the row above and below the selected row. Doing this in a the OnPaint...
1
by: EO | last post by:
I am trying to use the MSFT data access application block on 3 machines. Machine 1: Sandbox environment; I installed the application block with the msi. The Sqlhelper class compiles & runs...
7
by: Joe Rigley | last post by:
Hi, I have a custom class with a public method. I want to perform a repose.redirect if an error occurs in the public method GetUserRoles. Unfortunately, Visual Studio 2003 is throwing an error...
0
by: Rahul Chatterjee | last post by:
Hello All I have designed a dotnet application using VB which basically takes a selection and passes value to a crystal report which in turn passes the value to a Stored procedure. After the...
3
by: C CORDON | last post by:
I am verry confused about classes. I understand that classes can encapsulate properties, methods, events (don't know hoy to add events to a class), etc. I am confused with this: if you can...
3
by: Michael Tissington | last post by:
I'm confused by documentation and examples on using Delegate to create Events for use with COM In some situation I see a parameter list of (sender as Object, e as EventArgs) and other times I...
2
by: tshad | last post by:
I have a Base Page Class that I built am just starting to use. In my aspx page I have: <%@ Page Language="VB" trace="true" ContentType="text/html" ResponseEncoding="iso-8859-1"...
1
by: Radu | last post by:
Hi. I have a class "MyCustomBoundColumn.vb" which looks like this ____________________________________________________________________ Imports System Imports System.Web.UI.WebControls ...
5
by: SAL | last post by:
Hello, I would like to be able to set the WHERE clause of a select statement on the fly. I have a DataAccess layer designed using the DataSet designer and a BusinessLogic layer using classes. The...
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
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,...
1
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...
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
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.