|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Type xxx not defined #2* 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 Try: Imports XXXXClsLib
Instead of: imports XXXXClsLib.VVDB chaz wrote: Show quoteHide quote > 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 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 Show quoteHide quote "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 > > 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. Below is the VB.net specification regarding "Import Aliases" and
"6.3.1 Import Aliases" http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbls7/html/ vblrfVBSpec5_2_1.asp "6.3.2 Namespace Imports" http://msdn.microsoft.com/library/default.asp?url=/library/en-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. 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: Show quoteHide quote > Below is the VB.net specification regarding "Import Aliases" and > "6.3.1 Import Aliases" > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbls7/html/ > vblrfVBSpec5_2_1.asp > "6.3.2 Namespace Imports" > http://msdn.microsoft.com/library/default.asp?url=/library/en-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. > > 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. Chaz,
In addition to ssta > says use XXXXClsLib.VVDB Than it is not using the import, you have described the full path.> Cor
Trying to understand API calls
If you connect to Oracle through .NET please help! change progressbar bar color dataadapter and stored procs in design time get first 50 characters How to password protect a folder or similar Drawing vertical string Problems with structure in structure and DLL function call in VB.NET Visual Basic 6.0 & Sql Server 2005 Compatibility? Problems with structure in structure and DLL function call in VB.NET |
|||||||||||||||||||||||