tiredofit
Well-known Member
- Joined
- Apr 11, 2013
- Messages
- 1,832
- Office Version
- 365
- 2019
- Platform
- Windows
The code below starts if the user clicks a button on the userform.
The idea is it loops until the user enters "Apples" or clicks the "No" button on the messagebox.
The problem is if the user enters the wrong value more than one, say n times, if he eventually clicks "No", the messagebox pops up n times. I want it to only pop up once.
To fix it, I had to add an extra line, as per the below, to make it work:
Why is that?
Thanks
The idea is it loops until the user enters "Apples" or clicks the "No" button on the messagebox.
The problem is if the user enters the wrong value more than one, say n times, if he eventually clicks "No", the messagebox pops up n times. I want it to only pop up once.
Code:
Dim Response As Variant
Do Until Response = vbNo
Select Case Me.txtbox.Value
Case "Apples"
Unload Me
Case Else
Unload Me
Response = MsgBox(Prompt:="Wrong, repeat?", Buttons:=vbYesNo)
If Response = vbNo Then
' Do something
Else
MyUserform.Show
End If
End Select
Loop
To fix it, I had to add an extra line, as per the below, to make it work:
Code:
Dim Response As Variant
Do Until Response = vbNo
Select Case Me.txtbox.Value
Case "Apples"
Unload Me
Case Else
Unload Me
Response = MsgBox(Prompt:="Wrong, repeat?", Buttons:=vbYesNo)
If Response = vbNo Then
' Do something
Else
MyUserform.Show
'**********
Response = vbNo 'HAD TO ADD THIS LINE TO FIX IT
'**********
End If
End Select
Loop
Why is that?
Thanks