Search code examples
vbscript

If correct then goto


I know that there is no goto function in VBS, but I am wondering if you can goto a location using a different type of function.

Here is an example of what i want:

Pass=inputbox("Enter Password")

:start:
if Pass = "123" then goto end else Msgbox("wrong password")
'code
goto start

:end:
Msgbox("correct")
'code

Solution

  • Jumping around is bad programming. Why can't you use simple loop to achieve this? Something like

    varCheck=True
    Do While varCheck
        Pass=InputBox("Enter Password")
        If Pass = "123" Then
            varCheck=False
            Exit Do
        Else
            Msgbox("Wrong Password...Try Again")
        End If
    Loop
    Msgbox ("After Do While")