Password Learn programming Visual Basic (VB.net)

Lesson:

Flow Control


Exercise:

Password 13


Objetive:

Write a Visual Basic (VB.net) program to ask the user for his/her login and his/her password (both must be integer numbers) and repeat it as many times as necessary, until the entered login is "12" and the password is "1234".


Code:

Imports System
Public Class Exercise30
    Public Shared Sub Main()
        Dim user, pass As Integer

        Do
            Console.Write("Enter a user:  ")
            user = Convert.ToInt32(Console.ReadLine())
            Console.Write("Enter a password:  ")
            pass = Convert.ToInt32(Console.ReadLine())
            If (user <> 12) OrElse (pass <> 1234) Then Console.WriteLine("Login Error")
        Loop While (user <> 12) OrElse (pass <> 1234)

        Console.WriteLine("Login successful")
    End Sub
End Class