我正在學習visual basic online,但是我們只是得到了一個老師開關,他們沒有回答我的問題。所以我想我不妨在這裏問一下。我們被要求製作一個僅使用文本框,標籤和按鈕的計算機故障排除程序。我寫了這段代碼,但是當我運行它時,我得到這個錯誤「從字符串」Y「轉換爲鍵入'Boolean'是無效的。」我不知道爲什麼或如何解決它。謝謝您的幫助。從字符串「Y」到類型「布爾」的轉換無效
Private Sub btnHelp_Click(sender As Object, e As System.EventArgs) Handles btnHelp.Click
Dim strBeep As String
Dim strHDD As String
strBeep = Me.txtBeep.Text
strHDD = Me.txtHDD.Text
If strBeep And strHDD = "Y" Then
Me.lblMessage.Text = "Contact tech support."
ElseIf strBeep = "Y" And strHDD = "N" Then
Me.lblMessage.Text = "Check drive contacts."
ElseIf strBeep And strHDD = "N" Then
Me.lblMessage.Text = "Bring computer to repair center."
ElseIf strBeep = "N" And strHDD = "Y" Then
Me.lblMessage.Text = "Check the speaker connections."
End If
End Sub
End Class
感謝那些做了。如果他們實施這種改變會更好,因爲這會節省時間,他們都在檢查同樣的事情。 – Photoshopper 2012-02-25 07:10:01