I am learning visual basic online, however we just got a teacher switch and they have not replied to my question. So I figured I might as well ask it here. We where asked to make a computer troubleshooting program that only uses text boxes, labels, and a button. I wrote this code but when I run it I get this error “Conversion from string “Y” to type ‘Boolean’ is not valid.” and I have no idea why or how to fix it. Thanks for the help.
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
You are using
strBeepin an if condition without comparing it to something. This is a text and it can’t be converted toboolean.Do this:
instead of
Complete if conditions: