none
I'm having issues making a label show a random selection for a football team matchup

    Question

  • I'm a high school student in programming 1, and I missed a day of class so I have no clue what I am doing, and I was wondering if anyone could help me figure out how to do this. It's for a class project I have, and I need to understand it before I get swamped with work.

    Public Class Form1
        'Jacob Glugla
        '04/20/2017
        'Football matchup
        Dim AFC As String = "" 'makes AFC variable
        Dim NFC As String = "" 'makes NFC variable
        Dim AFCO As Integer 'makes AFCO variable
        Dim AFCD As Integer 'makes AFCD variable
        Dim NFCO As Integer 'makes NFCO variable
        Dim NFCD As Integer 'makes NFCD variable
        Dim teams As New System.Random 'makes team1 random
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            AFC = teams.Next(16)
            NFC = teams.Next(16)
            If AFC = 0 Then
                AFC = "Buffalo Bills"
                AFCO = 83
                AFCD = 83
            ElseIf AFC = 1 Then
                AFC = "Miami Dolphins"
                AFCO = 81
                AFCD = 81
            ElseIf AFC = 2 Then
                AFC = "New England Patriots"
                AFCO = 89
                AFCD = 91
            ElseIf AFC = 3 Then
                AFC = "New York Jets"
                AFCO = 77
                AFCD = 83
            ElseIf AFC = 4 Then
                AFC = "Houston Texans"
                AFCO = 81
                AFCD = 85
            ElseIf AFC = 5 Then
                AFC = "Indianapolis Colts"
                AFCO = 81
                AFCD = 79
            ElseIf AFC = 6 Then
                AFC = "Jacksonville Jaguars"
                AFCO = 81
                AFCD = 81
            ElseIf AFC = 7 Then
                AFC = "Tennesee Titans"
                AFCO = 85
                AFCD = 85
            ElseIf AFC = 8 Then
                AFC = "Baltimore Ravens"
                AFCO = 85
                AFCD = 83
            ElseIf AFC = 9 Then
                AFC = "Cincinatti Bengals"
                AFCO = 87
                AFCD = 87
            ElseIf AFC = 10 Then
                AFC = "Cleveland Browns"
                AFCO = 75
                AFCD = 77
            ElseIf AFC = 11 Then
                AFC = "Pittsburgh Steelers"
                AFCO = 93
                AFCD = 81
            ElseIf AFC = 12 Then
                AFC = "Denver Broncos"
                AFCO = 75
                AFCD = 91
            ElseIf AFC = 13 Then
                AFC = "Kansas City Chiefs"
                AFCO = 81
                AFCD = 93
            ElseIf AFC = 14 Then
                AFC = "Oakland Raiders"
                AFCO = 89
                AFCD = 85
            ElseIf AFC = 15 Then
                AFC = "San Diego Chargers"
                AFCO = 83
                AFCD = 85
            End If
            If NFC = 0 Then
                NFC = "Dallas Cowboys"
                NFCO = 89
                NFCD = 83
            ElseIf NFC = 1 Then
                NFC = "New York Giants"
                NFCO = 83
                NFCD = 83
            ElseIf NFC = 2 Then
                NFC = "Philadelphia Eagles"
                NFCO = 83
                NFCD = 83
            ElseIf NFC = 3 Then
                NFC = "Washington Redskins"
                NFCO = 83
                NFCD = 81
            ElseIf NFC = 4 Then
                NFC = "Atlanta Falcons"
                NFCO = 89
                NFCD = 79
            ElseIf NFC = 5 Then
                NFC = "Carolina Panthers"
                NFCO = 91
                NFCD = 87
            ElseIf NFC = 6 Then
                NFC = "New Orleans Saints"
                NFCO = 83
                NFCD = 79
            ElseIf NFC = 7 Then
                NFC = "Tampa Bay Buccaneers"
                NFCO = 83
                NFCD = 81
            ElseIf NFC = 8 Then
                NFC = "Chicago Bears"
                NFCO = 73
                NFCD = 77
            ElseIf NFC = 9 Then
                NFC = "Detroit Lions"
                NFCO = 81
                NFCD = 83
            ElseIf NFC = 10 Then
                NFC = "Green Bay Packers"
                NFCO = 89
                NFCD = 85
            ElseIf NFC = 11 Then
                NFC = "Minnesota Vikings"
                NFCO = 81
                NFCD = 87
            ElseIf NFC = 12 Then
                NFC = "Arizona Cardinals"
                NFCO = 91
                NFCD = 81
            ElseIf NFC = 13 Then
                NFC = "Los Angeles Rams"
                NFCO = 79
                NFCD = 81
            ElseIf NFC = 14 Then
                NFC = "San Francisco 49ers"
                NFCO = 75
                NFCD = 79
            ElseIf NFC = 15 Then
                NFC = "Seattle Seahawks"
                NFCO = 83
                NFCD = 89
            End If
        End Sub
    End Class


    • Edited by Aluranillo Friday, April 21, 2017 2:06 PM Clarification
    Friday, April 21, 2017 2:03 PM

Answers

  • I'm a high school student in programming 1, and I missed a day of class so I have no clue what I am doing, and I was wondering if anyone could help me figure out how to do this.

    Based on your thread title, it seems you are missing the last little bit of code:

            End If
        labelNFC.text = NFC 
        labelNFCO.text = NFCO.ToString 
        labelNFCD.text = NFCD.ToString 
        End Sub
    End Class
    

    where labelxxx are the labels you created on your form to display the results of the random selection.

    You should always include a description of the result you expect to get with any code you post.

    • Marked as answer by Aluranillo Tuesday, April 25, 2017 1:04 PM
    Friday, April 21, 2017 10:21 PM

All replies

  • Probably you missed the session about the Select Case

    https://msdn.microsoft.com/en-us/library/cy37t14y.aspx


    Success
    Cor

    Friday, April 21, 2017 2:44 PM
  • It seems you are creating 2 random values between 0 and 15, then assigning values to AFC and NFC parameters based on these random values...

    What's your question precisely?

    Friday, April 21, 2017 2:45 PM
  • I'm a high school student in programming 1, and I missed a day of class so I have no clue what I am doing, and I was wondering if anyone could help me figure out how to do this.

    Based on your thread title, it seems you are missing the last little bit of code:

            End If
        labelNFC.text = NFC 
        labelNFCO.text = NFCO.ToString 
        labelNFCD.text = NFCD.ToString 
        End Sub
    End Class
    

    where labelxxx are the labels you created on your form to display the results of the random selection.

    You should always include a description of the result you expect to get with any code you post.

    • Marked as answer by Aluranillo Tuesday, April 25, 2017 1:04 PM
    Friday, April 21, 2017 10:21 PM
  • You can use the Math.Round method to reduce each of the Double numbers to 2 places.  For example:

    bal = Math.Round(bal, 2)


    Solitaire

    Saturday, April 22, 2017 4:10 PM