469,658 Members | 1,844 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,658 developers. It's quick & easy.

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 1604
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

15 posts views Thread by Terje Slettebų | last post: by
4 posts views Thread by Jacob Jensen | last post: by
21 posts views Thread by Nitin Bhardwaj | last post: by
3 posts views Thread by phil | last post: by
7 posts views Thread by Michael | last post: by
70 posts views Thread by garyusenet | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.