VB code help in my code I have duplicate answers on my radio buttons


#1

Hi my vb code is showing duplicate answers on the radio buttons could you correct it for me using the code that I have given

    Dim CountryNames(5) As String 'creating the country names array'
    CountryNames(0) = "United Kingdom"
    CountryNames(1) = "France"
    CountryNames(2) = "Brazil"
    CountryNames(3) = "Spain"
    CountryNames(4) = "United States of America (USA)"
    CountryNames(5) = "Russia"

    flag.ImageUrl = Flagimageurl(5 * Rnd()) 'Choosing a random flag'
    RadioButton1.Text = CountryNames(5 * Rnd()) 'Randomly picks the country according to the CountryNames array'
    RadioButton2.Text = CountryNames(5 * Rnd())  ' with random * 6 you get blanks so you need to use random * 5'
    RadioButton3.Text = CountryNames(5 * Rnd())
    RadioButton4.Text = CountryNames(5 * Rnd())

    If RadioButton1.Text = RadioButton2.Text Then 'Makes sure that the radiobuttons don't show duplicate answers'
        RadioButton2.Text = CountryNames(5 * Rnd())
    End If

    If RadioButton2.Text = RadioButton1.Text Then
        RadioButton1.Text = CountryNames(5 * Rnd())
    End If

    If RadioButton3.Text = RadioButton1.Text Or RadioButton2.Text = RadioButton3.Text Then
        RadioButton3.Text = CountryNames(5 * Rnd())
    End If

    If RadioButton4.Text = RadioButton1.Text Or RadioButton2.Text = RadioButton3.Text Then
        RadioButton4.Text = CountryNames(5 * Rnd())
    End If

End Sub

End Class