We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,866 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Absolute Beginner - Test Application Help!

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

3
Contributors
3
Replies
7 Hours
Discussion Span
1 Year Ago
Last Updated
4
Views
aaronoafc
Newbie Poster
2 posts since Dec 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Anyone???

aaronoafc
Newbie Poster
2 posts since Dec 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

I think that you need to change

Console.ReadLine()

to

uservalue = Console.ReadLine()

,

adam_k
Veteran Poster
1,057 posts since Jun 2011
Reputation Points: 274
Solved Threads: 205
Skill Endorsements: 11

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.

Begginnerdev
Practically a Posting Shark
861 posts since Apr 2010
Reputation Points: 184
Solved Threads: 142
Skill Endorsements: 8

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0866 seconds using 2.65MB