Okay I did what Jewel said but it didin't work...
VB Code:
Private Sub Continue_Click() If IsNumeric(Answer.Text) = True Then 'check for correct data type' MsgBox "You've answered in the wrong data type, please enter in alphabet letters", 1 + 48, "Error" 'message box shown if the user enters their answer in numbers' Else If Answer.Text = "" Then MsgBox "You havn't answered yet!", 1 + 48, "Come on..." Else If (Answer.Text = "bread") Then 'If correct answer then' Users_score = Users_score + 1 'add one to the score' End If End If End If Unload Q2 'closes Question 1 form' Ans_2.Show 'loads Answer and comment form for question 1' End Sub
The first code I sent you works fine for memaybe we can revised your code to this:
VB Code:
Private Sub Continue_Click() '------------------------------ ' validate first input If Answer.Text = "" Then MsgBox "You havn't answered yet!", 1 + 48, "Come on..." Answer.SetFocus Exit Sub End If If IsNumeric(Answer.Text) = True Then 'check for correct data type' MsgBox "You've answered in the wrong data type, please enter in alphabet letters", 1 + 48, "Error" 'message box shown if the user enters their answer in numbers' Answer.SetFocus Exit Sub End If '--------------------------------------------- If (Answer.Text = "bread") Then 'If correct answer then' Users_score = Users_score + 1 'add one to the score' End If Unload Q2 'closes Question 1 form' Ans_2.Show 'loads Answer and comment form for question 1' End Sub
or you can make a function returning true if the input is valid like Jackalx25 did
VB Code:
Private Sub Continue_Click() If IsValid(Answer.Text) = True Then If (Answer.Text = "bread") Then 'If correct answer then' Users_score = Users_score + 1 'add one to the score' End If Else MsgBox "Invalid Answer!!" Answer.SetFocus End If Unload Q2 'closes Question 1 form' Ans_2.Show 'loads Answer and comment form for question 1' End Sub Private Function IsValid(str As String) As Boolean IsValid = True If Answer.Text = "" Or IsNumeric(Answer.Text) = True Then IsValid = False End If End Function




maybe we can revised your code to this:
Reply With Quote