Cry about...
MS-Windows Troubleshooting
Name 'NNNN' is not declared
Symptom:
When compiling, the compiler generates the following error:
Name 'NNNN' is not declared.'
where 'NNNN' is the name of a variable.
Cause:
The compiler does not recognise the variable 'NNNN'.
This is either because the variable name is miss-spelt or because
the compiler could not find a corresponding definition.
Remedy:
- A common cause is a simple misspelling where the identifier
is used. For example:
dim number as Integer;
numbr := 1;
Here the identifier is defined as 'number' but
used in the code as 'numbr'. The solution is to
correct the spelling.
- If the name is referring to an identifier then it may be
that the reference needs to be qualified. For example:
Imports System.Web.HttpContext
Module Example
Function ExampleProc() as String
return Application("name")
.
.
[Error] Name 'Application' is not declared.
Try replacing "Application" with
"Current.Application".
- The most common cause is that the namespace that defines the
name is missing. Identify and import the required namespace.
The following table (which is not exhaustive) lists identifiers
together with the namespace and any qualification that might
typically be
required:
| Name |
Namespace |
Qualified Name |
| Abs |
Math |
Math.Abs |
| AnchorStyles |
System.Windows.Forms |
|
| Application |
System.Web.HttpContext |
Current.Application |
| CultureInfo |
System.Globalization |
|
| Current |
System.Web.HttpContext |
|
| Debug |
System.Diagnostics |
|
| Directory |
System.IO |
|
| Encoding |
System.Text |
|
| EventLog |
System.Diagnostics |
|
| File |
System.IO |
|
| HtmlEncode |
System.Web.HttpUtility |
|
| HttpContext |
System.Web |
|
| HttpRuntime |
System.Web |
|
| HttpUtility |
System.Web |
|
| ImageFormat |
System.Drawing.Imaging |
|
| Marshal |
System.Runtime.InteropServices |
|
| Request |
System.Web.HttpContext |
Current.Request |
| Round |
Math |
Math.Round |
| Server |
System.Web.HttpContext |
Current.Server |
| SmptMail |
System.Web.Mail |
|
| User |
|
HttpContext.Current.User |
These notes are believed to be correct for VB.NET
for .NET 1.1 and .NET 2, and may apply to other versions as well.
|