在Visual Basic 2010中调试时如何输出代码? [英] How do I output code while debugging in Visual Basic 2010?

查看:189
本文介绍了在Visual Basic 2010中调试时如何输出代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我正在调试我的应用程序时,不正确,我不能继续。
那么当我测试它的时候可以看到我的应用程序的输出代码,看看有什么问题吗?



我打开输出窗口,但没有发生在那里,它只是保持空白。
用两个字:我想看看我的应用程序实际在做什么,而我正在测试它。
我使用的是Visual Studio 2010。

解决方案


我的应用程序的输出代码,而我测试它看看有什么问题?


是的,但你实际上必须输出某事,否则什么都不会出现。在VB.NET(这是您使用的语言,如果您有Visual Studio 2010),这是通过以下代码完成的:

  Debug.Print(这是一些将输出的文本)

文档对于 Debug.Print 方法是这里。为了这样调用,您还必须导入 System.Diagnostics 命名空间。您可以通过将以下行放在代码文件的顶部(与所有其他语句一样):

  Imports System.Diagnostics 

输出将自动出现在输出窗口中。如果仍然看不到任何内容,请确保输出没有被重定向到立即窗口:工具 - >选项 - >调试 - >常规 - >取消选中将所有输出窗口文本重定向到立即窗口选项。 / p>




令人困惑的是,您在问题中使用代码一词,表示您希望看到[你的]应用程序测试它。我不知道代码是否真的意味着输出,在这种情况下,上面的解决方案将适用于您。



如果您的意思是代码,与程序的源代码一样,您可以使用IDE中的Break工具栏按钮(或按 Ctrl + Break )来暂停执行你的程序这将自动将您转回代码编辑器,当前正在执行的代码行突出显示。



Visual Studio具有一些非常强大的调试工具。如果您还没有一个如何使用它们的一般想法,我强烈建议您在其中或VB 2010中选择一本书,以便向您介绍这些内容。他们可以非常混乱地通过反复尝试学习,但如果你有一个很好的指导,那不是那么困难。花时间调试代码,而不是弄清楚如何使用IDE。


When I'm debugging my application something is not right, and I can't continue. So is it possible to see the output code of my app while I'm testing it to see what is wrong?

I open the output window but nothing happens in there it's just stay blank. In two words: I want to see what my app is actually doing while I'm testing it. I'm using Visual Studio 2010.

解决方案

So is it possible to see the output code of my app while im testing it to see what is wrong?

Yes, but you actually have to output something, otherwise nothing will show up. In VB.NET (which is the language you're using if you have Visual Studio 2010), this is accomplished with the following code:

Debug.Print("Here is some text that will be output.")

The documentation for the Debug.Print method is here. In order to call it like that, you will also have to have imported the System.Diagnostics namespace. You do so by placing the following line at the top of your code file (with all the other statements that look like it):

Imports System.Diagnostics

The output will automatically appear in the Output Window. If you still don't see anything, ensure that output is not being redirected to the Immediate Window instead: Tools -> Options -> Debugging -> General -> uncheck the option "Redirect all Output Window text to the Immediate Window".


Confusingly, you use the word "code" in your question, saying that you wish to "see the output code of [your] app while testing it". I'm not sure if by "code" you actually mean "output", in which case the solution above will work for you.

If you actually mean code, as in your program's source code, then you can use the Break toolbar button (or press Ctrl+Break) in the IDE to pause the execution of your program. This will automatically dump you back into the code editor with the currently-executing line of code highlighted.

Visual Studio has some very powerful debugging tools. If you don't already have a general idea of how to use them, I strongly recommend picking up a book on either it or VB 2010 that will teach these things to you. They can be very confusing to learn by trial and error, but are not all that difficult if you have a good guide. Spend that time debugging your code, not figuring out how to use the IDE.

这篇关于在Visual Basic 2010中调试时如何输出代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆