我複製了我的教科書中的確切代碼,並且出現以下錯誤。Visual Basic 2010/Sub Procedure
Error 3 'txtOutput' is not declared. It may be inaccessible due to its protection level. C:\Users\Woong-Sup\AppData\Local\Temporary Projects\WindowsApplication1\Form1.vb 13 17 WindowsApplication1
Error 4 'txtOutput' is not declared. It may be inaccessible due to its protection level. C:\Users\Woong-Sup\AppData\Local\Temporary Projects\WindowsApplication1\Form1.vb 15 17 WindowsApplication1
Error 1 Handles clause requires a WithEvents variable defined in the containing type or one of its base types. C:\Users\Woong-Sup\AppData\Local\Temporary Projects\WindowsApplication1\Form1.vb 2 44 WindowsApplication1
請問誰能告訴我問題是什麼?如果我可以在MSN上添加你並提出更多問題,我將不勝感激!感謝
Public Class Form1
Private Sub btnDisplay_Click() Handles btnDisplay.Click
Dim anyDate As Date
anyDate = CDate(InputBox("Input a date. (mm/dd/yyyy)"))
ShowCentury(anyDate)
End Sub
Sub ShowCentury(ByVal anyDate As Date)
Select Case anyDate
Case Is >= #1/1/2000#
txtOutput.Text = "twenty-first century"
Case Is >= #1/1/1900#
txtOutput.Text = "twentieth century"
Case Else
txtOutput.Text = "prior to the twentieth century"
End Select
End Sub
End Class
哦,我會試試看:) – 2010-10-16 08:45:10
你的意思是AccessibleName,對吧?我改變了它,我設置了「 GenerateMember「屬性設置爲True,因爲你告訴我,但它仍然有相同的問題。:( – 2010-10-16 08:50:24
只是所以我們不會錯過任何顯而易見的東西......你的窗體被稱爲」Form1「,對吧?(如果不是,VB可能仍然會生成表單類,但是你的代碼不會成爲它的一部分 - 它只是一個額外的類。)不,我不是指AccessibleName - 這是爲了可訪問性東西(即:幫助盲人等),並且不應該影響控制是否出現在代碼中。 – cHao 2010-10-16 09:04:12