Results 1 to 8 of 8

Thread: Its suppose to have a trivia for each decade.Help!!( its a long program)

  1. #1
    New Member
    Join Date
    Aug 12
    Posts
    2

    Its suppose to have a trivia for each decade.Help!!( its a long program)

    only one decade is working for every decade. The errors are logical so i don't know where to start correcting them:
    Code:
    'this was suppose to be project 4 for final project but a1 prints for each decade, why?
    Module Module1
        Public Delegate Sub age()
        Sub Main()
            'at first I had this on top of sub main() and it wouldn't work
            Dim zero As New age(AddressOf a0)
    
            Dim one As New age(AddressOf a1)
    
            Dim two As New age(AddressOf a2)
    
            Dim three As New age(AddressOf a3)
            Dim four As New age(AddressOf a4)
            Dim five As New age(AddressOf a5)
            Dim six As New age(AddressOf a6)
            Dim seven As New age(AddressOf a7)
            Dim eight As New age(AddressOf a8)
            Dim nine As New age(AddressOf a9)
            Dim ten As New age(AddressOf a10)
            'now i have make the decision for each age using key word if
            Console.WriteLine(" This program will tell you your age once you type your today's date and date of birth. (press any key to continue)")
            Console.ReadKey()
            Console.Clear()
            'made some grammatical changes
            Console.WriteLine(" a trivia will pop up that will ask you questions about your birth decade.")
            Console.ReadKey()
            Console.WriteLine("Here are some tips: freshen up on what you know about your decade with factmonster.com.")
            Console.WriteLine("the program is case sensitive. Remember to put your uppercases where they need to be.")
            Console.ReadKey()
            Console.Clear()
            Console.WriteLine(" Finish freshening up? Here it goes!")
            Console.ReadKey()
            Console.Clear()
            'IT WORKED ON FIRST TRY!!!
            Try
                'did something wrong here. the wrong questions popped up for the trivia
    
                Console.WriteLine(" Enter birth month: (ex:March=03)")
                Dim p As Integer = Console.ReadLine()
                Console.WriteLine("enter day: (ex: 12)")
                Dim o As Integer = Console.ReadLine()
                Console.WriteLine("enter year: (ex: 1998)")
                Dim n As Integer = Console.ReadLine()
                Console.Clear()
                Console.WriteLine(" Enter current month: (ex:March=03)")
                Dim m As Integer = Console.ReadLine()
                Console.WriteLine("enter current day: (ex: 12)")
                Dim l As Integer = Console.ReadLine()
                Console.WriteLine("enter current year: (ex: 1998)")
                Dim h As Integer = Console.ReadLine()
                Console.Clear()
                Dim z As Integer = h - n
                If p > m Then
                    If o > l Then
                        z = z - 1
                    Else
                        z = z
                    End If
                Else
                    z = z
                End If
                Console.WriteLine(" you are:")
                Console.WriteLine(z)
                Console.ReadKey()
                Console.WriteLine("Now its time for some questions:")
                Console.Clear()
                Console.WriteLine(n)
                Console.ReadKey()
                If n < 1900 Then
                    Console.WriteLine(" The program does not have a trivia for a decade this early. Sorry.")
                    Console.ReadKey()
    
                ElseIf 1900 < n < 1910 Then
                    zero()
                    'a1 worked for the worng decade, why?
                ElseIf 1909 < n < 1920 Then
                    one()
                ElseIf 1919 < n < 1930 Then
                    two()
                ElseIf 1929 < n < 1940 Then
                    three()
                ElseIf 1939 < n < 1950 Then
                    four()
                ElseIf 1949 < n < 1960 Then
                    five()
                ElseIf 1959 < n < 1970 Then
                    six()
                ElseIf 1969 < n < 1980 Then
                    seven()
                ElseIf 1979 < n < 1990 Then
                    eight()
                ElseIf 1989 < n < 2000 Then
                    nine()
                ElseIf 1999 < n < 2010 Then
                    ten()
                Else
                    Console.WriteLine("this decade is not in the system. try again.")
                    Console.ReadKey()
                End If
                Console.Clear()
                Console.WriteLine(" thank you for playing!")
                Console.ReadKey()
                Console.Clear()
                Console.WriteLine(" please rate this program:(if not just exit out)")
                Console.WriteLine("E for excellent")
                Console.WriteLine(" G for good")
                Console.WriteLine("A for average")
                Console.WriteLine("D for displeasing")
                Dim c As String = Console.ReadLine()
                Console.Clear()
                If c = ("E") Then
                    Console.WriteLine(" thanks")
                ElseIf c = ("G") Then
                    Console.WriteLine(" thanks, I'm working on it")
                ElseIf c = ("A") Then
                    Console.WriteLine("It'll be better next time!")
                ElseIf c = ("D") Then
                    Console.WriteLine(" can you explain why it was bad so I can fix it next time:(if no just press enter)")
                    Console.ReadLine()
                    Console.WriteLine(" sorry for the inconvenience. It will be improved.")
                End If
            Catch ex As Exception
                Console.Clear()
                Console.WriteLine("please try again. The program only accept integers in the date.")
            End Try
            Console.ReadKey()
            'forgot,console.readkey()
        End Sub
    ' the whole thing could fit. The error is in the main sub somewhere
    Last edited by gep13; Aug 17th, 2012 at 06:37 AM. Reason: Added code tags

  2. #2
    New Member
    Join Date
    Aug 12
    Posts
    2

    Re: Its suppose to have a trivia for each decade.Help!!( its a long program)

    Code:
    ' here is the rest of the program.
        Sub a8()
            Dim i As Integer = 0
            Console.WriteLine("What Beatles member was shot in New York City?")
            If Console.ReadLine = ("John Lennon") Then
                Console.WriteLine("correct!")
    
                i = i + 1
            Else
                Console.WriteLine("wrong")
            End If
            'had to move this to the end of end if for it to work the way I want it to.
            Console.ReadKey()
            Console.Clear()
            Console.WriteLine("What major STD was identified?")
            If Console.ReadLine = ("AIDS") Then
                Console.WriteLine("correct!")
    
                i = i + 1
            Else
                Console.WriteLine("wrong")
            End If
            Console.ReadKey()
            Console.Clear()
            Console.WriteLine("What album did Micheal Jackson that became the biggest selling album in history?")
            If Console.ReadLine = ("Thriller") Then
                Console.WriteLine("correct!")
    
                i = i + 1
            Else
                Console.WriteLine("wrong")
            End If
            Console.ReadKey()
            Console.Clear()
            Console.WriteLine("What channel was the popular 'The Cosby Show' debuted on?")
            If Console.ReadLine = ("NBC") Then
                Console.WriteLine("correct!")
    
                i = i + 1
            Else
                Console.WriteLine("wrong")
    
            End If
            Console.ReadKey()
            Console.Clear()
            If i > 2 Then
                Console.WriteLine(" Most of your answers were right!")
            Else
                Console.WriteLine("try again.")
            End If
            Console.ReadKey()
        End Sub
        Sub a1()
            Dim i As Integer = 0
            Console.WriteLine("What famous 'unsinkable' ship sunk in 1912?")
            If Console.ReadLine = ("Titanic") Then
                Console.WriteLine("correct!")
    
                i = i + 1
            Else
                Console.WriteLine("wrong")
            End If
            'had to move this to the end of end if for it to work the way I want it to.
            Console.ReadKey()
            Console.Clear()
            Console.WriteLine("what year was the first assembly line developed?")
            If Console.ReadLine = ("1913") Then
                Console.WriteLine("correct!")
    
                i = i + 1
            Else
                Console.WriteLine("wrong")
            End If
            Console.ReadKey()
            Console.Clear()
            Console.WriteLine("where were the first traffic light installed?")
            If Console.ReadLine = ("Cleveland") Then
                Console.WriteLine("correct!")
    
                i = i + 1
            Else
                Console.WriteLine("wrong")
            End If
            Console.ReadKey()
            Console.Clear()
            Console.WriteLine("what year did Daylight Saving time start?")
            If Console.ReadLine = ("1918") Then
                Console.WriteLine("correct!")
    
                i = i + 1
            Else
                Console.WriteLine("wrong")
    
            End If
            Console.ReadKey()
            Console.Clear()
            If i > 2 Then
                Console.WriteLine(" Most of your answers were right!")
            Else
                Console.WriteLine("try again.")
            End If
            Console.ReadKey()
        End Sub
        Sub a2()
            Dim i As Integer = 0
            Console.WriteLine("what Renaissance started in 1920, led my African Americans?")
            If Console.ReadLine = ("Harlem") Then
                Console.WriteLine("correct!")
    
                i = i + 1
            Else
                Console.WriteLine("wrong")
            End If
            'had to move this to the end of end if for it to work the way I want it to.
            Console.ReadKey()
            Console.Clear()
            Console.WriteLine("What state was the Lincoln memorial dedicated to?")
            If Console.ReadLine = ("Washington D.C.") Then
                Console.WriteLine("correct!")
    
                i = i + 1
            Else
                Console.WriteLine("wrong")
            End If
            Console.ReadKey()
            Console.Clear()
            Console.WriteLine("what was Walt Disney's first cartoon?")
            If Console.ReadLine = ("Alice in Wonderland") Then
                Console.WriteLine("correct!")
    
                i = i + 1
            Else
                Console.WriteLine("wrong")
            End If
            Console.ReadKey()
            Console.Clear()
            Console.WriteLine("how much was the first television?")
            If Console.ReadLine = ("75") Then
                Console.WriteLine("correct!")
    
                i = i + 1
            Else
                Console.WriteLine("wrong")
    
            End If
            Console.ReadKey()
            Console.Clear()
            If i > 2 Then
                Console.WriteLine(" Most of your answers were right!")
            Else
                Console.WriteLine("try again.")
            End If
            Console.ReadKey()
        End Sub
        Sub a3()
            Dim i As Integer = 0
            Console.WriteLine("What was the cost of a stamp?(number form)")
            If Console.ReadLine = ("0.03") Then
                Console.WriteLine("correct!")
    
                i = i + 1
            Else
                Console.WriteLine("wrong")
            End If
            'had to move this to the end of end if for it to work the way I want it to.
            Console.ReadKey()
            Console.Clear()
            Console.WriteLine("when was the first successful helicopter ride?")
            If Console.ReadLine = ("1936") Then
                Console.WriteLine("correct!")
    
                i = i + 1
            Else
                Console.WriteLine("wrong")
            End If
            Console.ReadKey()
            Console.Clear()
            Console.WriteLine("what group sent thousands of Jews to concentration camps?")
            If Console.ReadLine = ("Nazis") Then
                Console.WriteLine("correct!")
    
                i = i + 1
            Else
                Console.WriteLine("wrong")
            End If
            Console.ReadKey()
            Console.Clear()
            Console.WriteLine("What year did World War II begin?")
            If Console.ReadLine = ("1939") Then
                Console.WriteLine("correct!")
    
                i = i + 1
            Else
                Console.WriteLine("wrong")
    
            End If
            Console.ReadKey()
            Console.Clear()
            If i > 2 Then
                Console.WriteLine(" Most of your answers were right!")
            Else
                Console.WriteLine("try again.")
            End If
            Console.ReadKey()
        End Sub
        Sub a4()
            Dim i As Integer = 0
            Console.WriteLine("What major cartoon began in 1940")
            If Console.ReadLine = ("Bugs Bunny") Then
                Console.WriteLine("correct!")
    
                i = i + 1
            Else
                Console.WriteLine("wrong")
            End If
            'had to move this to the end of end if for it to work the way I want it to.
            Console.ReadKey()
            Console.Clear()
            Console.WriteLine("What Italian facist ruler was arrested?")
            If Console.ReadLine = ("Mussolini") Then
                Console.WriteLine("correct!")
    
                i = i + 1
            Else
                Console.WriteLine("wrong")
            End If
            Console.ReadKey()
            Console.Clear()
            Console.WriteLine("What Jew, famous for her diary, was killed in 1945?")
            If Console.ReadLine = ("Anne Frank") Then
                Console.WriteLine("correct!")
    
                i = i + 1
            Else
                Console.WriteLine("wrong")
            End If
            Console.ReadKey()
            Console.Clear()
            Console.WriteLine("What year was the microwave oven invented?")
            If Console.ReadLine = ("1947") Then
                Console.WriteLine("correct!")
    
                i = i + 1
            Else
                Console.WriteLine("wrong")
    
            End If
            Console.ReadKey()
            Console.Clear()
            If i > 2 Then
                Console.WriteLine(" Most of your answers were right!")
            Else
                Console.WriteLine("try again.")
            End If
            Console.ReadKey()
        End Sub
        Sub a5()
            Dim i As Integer = 0
            Console.WriteLine("In 1951, color television was introduced in what country?")
            If Console.ReadLine = ("U.S.") Then
                Console.WriteLine("correct!")
    
                i = i + 1
            Else
                Console.WriteLine("wrong")
            End If
            'had to move this to the end of end if for it to work the way I want it to.
            Console.ReadKey()
            Console.Clear()
            Console.WriteLine("what year was the World Series broadcasted in color for the first time?")
            If Console.ReadLine = ("1954") Then
                Console.WriteLine("correct!")
    
                i = i + 1
            Else
                Console.WriteLine("wrong")
            End If
            Console.ReadKey()
            Console.Clear()
            Console.WriteLine("What was the unemployment rate in 1956?")
            If Console.ReadLine = ("4.4%") Then
                Console.WriteLine("correct!")
    
                i = i + 1
            Else
                Console.WriteLine("wrong")
            End If
            Console.ReadKey()
            Console.Clear()
            Console.WriteLine("What year did Frank Lloyd Wright die?")
            If Console.ReadLine = ("1959") Then
                Console.WriteLine("correct!")
    
                i = i + 1
            Else
                Console.WriteLine("wrong")
    
            End If
            Console.ReadKey()
            Console.Clear()
            If i > 2 Then
                Console.WriteLine(" Most of your answers were right!")
            Else
                Console.WriteLine("try again.")
            End If
            Console.ReadKey()
        End Sub
    'The rest of them looked the same, only different questions
    Last edited by gep13; Aug 17th, 2012 at 06:38 AM. Reason: Added code tags

  3. #3
    PowerPoster
    Join Date
    Feb 12
    Location
    West Virginia
    Posts
    4,957

    Re: Its suppose to have a trivia for each decade.Help!!( its a long program)

    Hard to read your code because you did not use code tags and have no formatting
    Code is in VB.Net not VB6

    The parts in red are useless and should be removed
    Code:
    If p > m Then
       If o > l Then
          z = z - 1
       Else
          z = z
       End If
    Else
       z = z
    End If
    Again hard to read the code but I would guess that you are getting a one when the dates fall in what you are expecting to be 0

  4. #4
    Frenzied Member
    Join Date
    Aug 11
    Location
    B.C., Canada
    Posts
    1,838

    Re: Its suppose to have a trivia for each decade.Help!!( its a long program)

    does not look like vb6 code(must be .net) ... you posted in wrong forum

  5. #5
    PowerPoster
    Join Date
    Jul 06
    Location
    Maldon, Essex. UK
    Posts
    5,156

    Re: Its suppose to have a trivia for each decade.Help!!( its a long program)

    I don't know much about VB.Net but I'm sure that a statement of this kind
    Code:
    ElseIf 1900 < n < 1910 Then
    is not doing what you think. You have to be explicit
    Code:
    ElseIf n > 1900 And n < 1910 Then

  6. #6
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 04
    Location
    The Granite City
    Posts
    21,744

    Re: Its suppose to have a trivia for each decade.Help!!( its a long program)

    Hello keekeee14,

    Welcome to the forums!

    When you are posting code into the forum, can you please remember to surround it in [code][/code] or [highlight][/highlight] tags? It makes it a lot easier to read. I have done this for you in your above post.

    Gary

  7. #7
    Super Moderator Hack's Avatar
    Join Date
    Aug 01
    Location
    Searching for mendhak
    Posts
    58,283

    Re: Its suppose to have a trivia for each decade.Help!!( its a long program)

    Moved To VB.NET
    Please use [Code]your code goes in here[/Code] tags when posting code.
    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum section.

    Creating A Wizard In VB.NET
    Paging A Recordset
    What is wrong with using On Error Resume Next
    Good Article: Language Enhancements In Visual Basic 2010
    Upgrading VB6 Code To VB.NET
    Microsoft MVP 2005/2006/2007/2008/2009/2010/2011/2012/Defrocked

  8. #8

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •