简体   繁体   中英

Using Visual Studio Immediate Window like VBA immediate window

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 .

确保您目前正在逐步完成代码。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM