Password 5 attempts Learn programming Visual Basic (VB.net)

Lesson:

Basic Data Types


Exercise:

Password 5 attempts 51


Objetive:

Write a Visual Basic (VB.net) program which asks the user for his login and password. Both must be strings. After 5 wrong attempts, the user will be rejected.


Code:

Imports System
Public Class Exercise52
    Public Shared Sub Main()
        Dim user, pass As String
        Dim count As Integer = 0

        Do
            Console.Write("Enter username: ")
            user = Console.ReadLine()
            Console.Write("Enter password: ")
            pass = Console.ReadLine()
            count += 1
        Loop While ((user <> "user") OrElse (pass <> "password")) AndAlso (count <> 5)

        If count = 5 Then
            Console.Write("Login attemp fail!")
        Else
            Console.Write("Password correct!")
        End If
    End Sub
End Class