VbNet · Console
Option Strict On
Imports System
Public Module Module1
Public Sub Main()
'Prompt for my name
Console.Write("What is my name: ")
'Declare a variable to store the input
Dim input As String = Console.ReadLine()
'Loop while the input is not my name
Do While input <> "David"
'Indicate that they guessed wrong and to try again
Console.WriteLine("Nope, that is not it.")
Console.Write("What is my name: ")
input = Console.ReadLine()
Loop
'Indicate that they guessed correctly
Console.WriteLine("Good job! My name is David.")
'Reset the variable and prompt for the name at the end of the loop
input = String.Empty
Do
'Prompt for the name
Console.WriteLine("What is my name: ")
input = Console.ReadLine()
'Check if the input does not match my name
If input <> "David" Then
Console.WriteLine("Nope, that is not it.")
End If
Loop While input <> "David"
'Indicate that they guessed correctly
Console.WriteLine("Good job! My name is David.")
End Sub
End Module