Domanda

In the VBA immediate window, I can simply type the following at any time:

?Len("Four")

Press enter and get the result:

4

If I try to do that in Visual Studio Express (VB.NET), I get the following result:

The name 'Len' does not exist in the current context

I assume it has to do with VBA being a "scripting" language and VB.Net requiring compilation. I'm just looking for a simple way to evaluate expressions using functions from the built-in libraries.

È stato utile?

Soluzione

I just created a new console app and tested both

?"Four".Length

and

?Len("Four")

both of which result in 4, after my project has run.

Do you have a project that will run? The immediate window needs to be evaluated in the context of a running project. If so,

Have you imported Microsoft.VisualBasic in your project properties "References" tab? If I remove that I get,

'Len' is not declared. It may be inaccesible due to its protection level.

But, the Length propery of System.String still works because I'm still importing System.

Altri suggerimenti

Make sure you are currently stepping through your code.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top