Password V2 Learn programming Visual Basic (


Flow Control


Password V2


Write a Visual Basic ( program to ask the user for their login and password (both must be integer numbers) until the entered login is "12" and the password is "1234". The user will have a maximum of three attempts.


Imports System
Public Class Exercise31
    Public Shared Sub Main()
        Dim user, pass As Integer
        Dim counter As Integer = 0

            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")
                counter += 1
            End If
        Loop While ((user <> 12) OrElse (pass <> 1234)) AndAlso (counter <> 3)

        If (user <> 12) OrElse (pass <> 1234) Then
            Console.WriteLine("Logged out!")
            Console.WriteLine("Login successful")
        End If
    End Sub
End Class

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