1.11M Members

Absolute Beginner - Test Application Help!

 
0
 

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

 
0
 

Anyone???

 
0
 

I think that you need to change

Console.ReadLine()

to

uservalue = Console.ReadLine()

,

 
0
 

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.

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: