Private Sub btnSubmit_Click(sender As Object, e As EventArgs) Handles btnSubmit.Click
Dim difficulty As Integer 'Sets difficulty as integer
If txtBack.Visible = True Or btnDisplay.Enabled = False Then 'if back of the flashcard is visible and if the start button has been clicked
If Integer.TryParse(TxtDifficulty.Text, difficulty) AndAlso difficulty >= 1 AndAlso difficulty <= 3 Then 'If diffiuclty is between 1 and 3
Dim front = txtFront.Text 'Defines front as variable which is equal to txtfront.text
UpdateDifficultyLevel(front, difficulty) 'Calls subroutine
MsgBox("Difficulty updated succesfully") 'outputs messagebox saying difficulty has been updated succesfully
Else 'If user input is not an integer
MsgBox("Please enter a number between 1 and 3") ' tells user that the difficulty must be a number
End If
Else 'If back of the flashcard is not visible and is start button has not been clicked
MsgBox("Please display the flashcard") 'Tells user to display flashcard.
End If
End Sub
This code is supposed to check if txtback.visible = true or btndisplay.enabled = false then runs the appropriate code. However only the txtback.visible works. How would I get the code to also check if btndisplay.enabled = false?
CodePudding user response:
Are you sure you want to use Or? The comment on that if statement says: "if condition1 AND condition2 are true, then...". In that case, if you want both to be checked and evaluated as true just do
If txtBack.Visible = True And btnDisplay.Enabled = False Then