473,498 Members | 1,741 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Type xxx not defined #2

Hi,
* this class is defined in assembly XXXXClsLib :
Public class VVDB : inherits DBFuncs
...
* Assembly YYYYFwApi has a reference to XXXXClsLib
* this class B in YYYYFwApi has an imports stmt :
imports XXXXClsLib.VVDB

* and this code of class b gives an error
Private Function zzz() As String

Dim myvvdb as new VVDB <<- VVDB not defined

and an error correction via shift+alt+f10

says use XXXXClsLib.VVDB

well why is that ?

also if I change the imports to

imports VVDB = XXXXClsLib.VVDB

then all is well.

why is that ?

thanks for explanation

Jun 23 '06 #1
7 1728
Try: Imports XXXXClsLib
Instead of: imports XXXXClsLib.VVDB
chaz wrote:
Hi,
* this class is defined in assembly XXXXClsLib :
Public class VVDB : inherits DBFuncs
...
* Assembly YYYYFwApi has a reference to XXXXClsLib
* this class B in YYYYFwApi has an imports stmt :
imports XXXXClsLib.VVDB

* and this code of class b gives an error
Private Function zzz() As String

Dim myvvdb as new VVDB <<- VVDB not defined

and an error correction via shift+alt+f10

says use XXXXClsLib.VVDB

well why is that ?

also if I change the imports to

imports VVDB = XXXXClsLib.VVDB

then all is well.

why is that ?

thanks for explanation


Jun 23 '06 #2
yeah that works as well, but why? I have another class in the same assembly
wich requires XXXClsLib.classname in the imports stmt else it's undefined .
Am I missing some underlying concept or is it just try until it works?

thanks
"ssta" wrote:
Try: Imports XXXXClsLib
Instead of: imports XXXXClsLib.VVDB
chaz wrote:
Hi,
* this class is defined in assembly XXXXClsLib :
Public class VVDB : inherits DBFuncs
...
* Assembly YYYYFwApi has a reference to XXXXClsLib
* this class B in YYYYFwApi has an imports stmt :
imports XXXXClsLib.VVDB

* and this code of class b gives an error
Private Function zzz() As String

Dim myvvdb as new VVDB <<- VVDB not defined

and an error correction via shift+alt+f10

says use XXXXClsLib.VVDB

well why is that ?

also if I change the imports to

imports VVDB = XXXXClsLib.VVDB

then all is well.

why is that ?

thanks for explanation


Jun 23 '06 #3
Chaz,

In addition to ssta
says use XXXXClsLib.VVDB

Than it is not using the import, you have described the full path.

Cor

Jun 23 '06 #4
Hi Chaz,

Thanks for your post!

I assume VVDB is a class name not a namespace name.

In VB.net syntax, there are 2 types of "Imports" statement: "Imports Alias"
and "Namespace Imports".
1. An import alias defines an alias for a namespace or type
2. A namespace import imports all of the members of a namespace or type,
allowing the identifier of each member of the namespace or type to be used
without qualification.

In your scenario, you are using "Namespace Imports" to eliminate the
namespace qualification of "VVDB" class, so you should "Imports" the
namespace of "VVDB" class instead of "Imports" this class itself. Let's
take another example: to use FileStream class in System.IO namespace, we
should import System.IO namespace instead of System.IO.FileStream itself.
If we import System.IO.FileStream itself, the compiler still can not see
FileStream class, because FileStream class is not declared under
System.IO.FileStream, but System.IO.

Imports System.IO.FileStream
Public Class Form1
Inherits System.Windows.Forms.Form

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim fs As New FileStream '<<this statement generates compile time
error
End Sub
End Class

Why does "imports VVDB = XXXXClsLib.VVDB" eliminate the compile error? This
"imports" applies to "Imports Alias", not "Namespace Imports". By doing
this, you are saying VVDB is an alias of XXXXClsLib.VVDB class, so in
compile time, the compiler will automatically substitute your typed "VVDB"
with "XXXXClsLib.VVDB" class.

Hope this explanation makes things clear.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 26 '06 #5
Below is the VB.net specification regarding "Import Aliases" and
"6.3.1 Import Aliases"
http://msdn.microsoft.com/library/de...us/vbls7/html/
vblrfVBSpec5_2_1.asp
"6.3.2 Namespace Imports"
http://msdn.microsoft.com/library/de...us/vbls7/html/
vblrfVBSpec5_2_2.asp

For your information.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 26 '06 #6
Hi Jeffrey,
Here is where I got confused (and still am)
Assembly A has to classes

public class VVDB
public function vvx()

public class ASPutility

public shared function Aspfunc() as object <<= note shared

Assembly B has theses two imports

imports A.Asputility
imports A

the 2nd is so we can write
Dim vvdb as new VVDB
instead of
Dim vvdb as new A.VVDB
(which has been discussed )

but the first is so we can write
xxx = AspFunc

instead of
xxx = A.AspFunc

""Jeffrey Tan[MSFT]"" wrote:
Below is the VB.net specification regarding "Import Aliases" and
"6.3.1 Import Aliases"
http://msdn.microsoft.com/library/de...us/vbls7/html/
vblrfVBSpec5_2_1.asp
"6.3.2 Namespace Imports"
http://msdn.microsoft.com/library/de...us/vbls7/html/
vblrfVBSpec5_2_2.asp

For your information.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 26 '06 #7
Hi Scott,

Thanks for your feedback!

Yes, this condition falls in the "Namespace Imports" syntax of VB.net. As
you can see in "6.3.2 Namespace Imports", a namespace imports can not only
import a namespace, can it also import a type(class):
"In the case of types, a namespace import only allows access to the shared
members of the type without requiring qualification of the class name. "

This explains why you can eliminate the usage of class name in front of the
shared method.

Additionally, if you are curious, based on my test, the C# "using"
statement(which is the counterpoint to "imports" statement) does not
support this feature. "using" statement can only import the namespace, it
can not be used to import the class/type.

Hope this helps!

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 27 '06 #8

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

Similar topics

15
2304
by: Terje Slettebø | last post by:
Hi. I'm new here, and sorry if this has been discussed before; I didn't find it searching the PHP groups. (I've also read recommendations to cross-post to the other PHP groups, but if that is...
4
2918
by: Jari Kujansuu | last post by:
I can successfully parse XML document using SAX or DOM and I can also validate XML document against schema. Problem is that my program should deal with user-defined schemas which means that when...
4
3438
by: Jacob Jensen | last post by:
This question has probably been asked a million time, but here it comes again. I want to learn the difference between the three type cast operators: static_cast, reinterpret_cast, dynamic_cast. A...
21
2477
by: Nitin Bhardwaj | last post by:
Hi all, It is said that C++ is a strongly typed language and thus a type-safe language (unlike C). So how does one explain the following behaviour : int main(void) { char *p = NULL; p = "A...
8
2216
by: Rade | last post by:
Following a discussion on another thread here... I have tried to understand what is actually standardized in C++ regarding the representing of integers (signed and unsigned) and their conversions....
13
10382
by: dawatson833 | last post by:
I have several stored procedures with parameters that are defined with user defined data types. The time it takes to run the procedures can take 10 - 50 seconds depending on the procedure. If I...
14
7381
by: Matt | last post by:
I want to know if "int" is a primitive type, or an object? For example, the following two approaches yield the same result. > int t1 = int.Parse(TextBox2.Text); //method 1 > int t2 =...
3
2775
by: phil | last post by:
I recently tried converting my asp.net 1.1 app to 2.0 in visual studio 2005 beta 2. I get several "type xxx is not defined" errors. It seems that some of my code file within my web application...
7
1939
by: Michael | last post by:
Hi, I could understand the difference between class and object. However, I could find out a good definiton of type. how to understand the relaitonship between type, class, and object? Thanks! ...
70
3284
by: garyusenet | last post by:
I'm using an example piece of code: - namespace Wintellect.Interop.Sound{ using System; using System.Runtime.InteropServices; using System.ComponentModel; sealed class Sound{ public static...
0
7002
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
7203
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...
1
6885
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
7379
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
5462
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,...
1
4908
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
3081
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
290
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...

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.