VB中的for循环有什么问题?

时间:2011-12-07 03:33:27

标签: vb.net

我完全不理解,为什么在VS2008SP1中点击Button1时我得到Additional information: Bad file name or number

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim i As Integer = 0
    Do
        i += 1
        Print(i)

        If i >= 10 Then
            Print "I is above 10"
        ElseIf i >= 20 Then
            Exit Do
        End If
    Loop While (i <= 30)
End Sub

2 个答案:

答案 0 :(得分:2)

不要使用Print()。 Print()函数用于将数据写入文件。要在调试窗口中打印数字,请使用Debug.Print()方法。

答案 1 :(得分:0)

你误用了打印功能 - http://msdn.microsoft.com/en-us/library/9cksc646(v=vs.90).aspx

您是否尝试输出到控制台或调试窗口?