문제

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.

도움이 되었습니까?

해결책

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.

다른 팁

Make sure you are currently stepping through your code.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top