Hi,

I'm a programming beginner and currently learning VB.net as a starting language. I have just been making a little test console application using visual studio asking about favourite football teams, please could someone tell me what I'm doing wrong? Below is the code, now I want the user to be able to type in their team "Oldham, Man city etc" Then it to come up with the message I have put there "Good lad, BOOOO" however At the minute it lets the user type in say "oldham" then when we hit enter it just closes the application down with out coming up with the corresponding message.

Dim uservalue As String = Console.ReadLine()

Console.WriteLine("What football team do you support? Oldham, Manchester City, or Manchester United?")
Console.ReadLine()

If uservalue = "oldham" Then
Console.WriteLine("Good lad latics!")
Console.ReadLine()
ElseIf uservalue = "Manchester City" Then
Console.WriteLine("BOOOOOOOOOOOOOOOOO!!!!")
Console.ReadLine()
ElseIf uservalue = "Manchester United" Then
Console.WriteLine("BOOOOOOOOOOOOOOOOO!!!!")
Console.ReadLine()
End If

Thanks
Aaron

Anyone???

I think that you need to change

Console.ReadLine()

to

uservalue = Console.ReadLine()

,

The above suggestion is correct, The program might also be terminating to fast for you to see.


Try wrapping the program with a while.

Like this:

Sub Main()
        Dim uservalue As String
        Dim ex As String = ""
        While ex <> "exit"
            Console.WriteLine("What football team do you support? Oldham, Manchester City, or Manchester United?")
            uservalue = Console.ReadLine()
            If uservalue = "oldham" Then
                Console.WriteLine("Good lad latics!")
            ElseIf uservalue = "Manchester City" Then
                Console.WriteLine("BOOOOOOOOOOOOOOOOO!!!!")
            ElseIf uservalue = "Manchester United" Then
                Console.WriteLine("BOOOOOOOOOOOOOOOOO!!!!")
            Else
                Console.WriteLine("I DONT KNOW WHO YOU ARE!")
            End If
            Console.WriteLine("Type exit to exit the application")
            ex = Console.ReadLine()
        End While
    End Sub

This allows you to loop through the program until you want to exit.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.