Search code examples
vbainputbox

What is wrong with my inputbox


Sub weewe()

Dim jjj As String

Do
    jjj = InputBox("Type in the correct password", "password")
Loop Until jjj = "Master" Or vbCancel

If jjj = "Master" Then

    sss = MsgBox("thats the correct password", vbOKOnly, "Password")

ElseIf jjj = vbCancel Then

    Exit Sub

End If

End Sub

the code works but why when i click cancel do i get an error 13? And how do I fix it?


Solution

  • Sub weewe()
    
        Dim jjj As String
    
        Do
            jjj = InputBox("Type in the correct password", "password")
        Loop Until jjj = "Master" Or jjj = ""
    
        If jjj = "Master" Then
            MsgBox "thats the correct password", vbOKOnly, "Password"
        ElseIf jjj = "" Then
            Exit Sub
        End If
    
    End Sub