Password Learn programming Visual Basic (VB.net)

Lesson:

Flow Control


Exercise:

Password


Objetive:

Write a Visual Basic (VB.net) program to prompt the user to enter their login and password (both must be integer numbers) and repeat the prompt 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

Juan A. Ripoll - Systems Tutorials and Programming Courses ©  All rights reserved.  Legal Conditions.