mercredi 2 décembre 2015

Pick Random Word

So for a school project I need to make a quiz thing using random words with one corresponding defintion. I written the following code, but all the words are the same, and when using breakpoints, it does what I want it to do. Any suggestions?

Dim randomize As Boolean = False
Dim Word(4) As String
Dim Definition As String
Dim wordNmb As Integer
Dim defineNmb As Integer
Dim rand As Random 

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    randomize = True
End Sub

Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles WordTimer.Tick
    rand = New Random

    If randomize = True Then
        randomize = False
        defineNmb = rand.Next(1, 5)
        For x As Integer = 1 To 4
            rand = New Random
            wordNmb = rand.Next(1, 6)

            Select Case wordNmb
                Case 1
                    Word(x) = "Absolve"
                    Definition = "To clear of guilt"
                Case 2
                    Word(x) = "Adamant"
                    Definition = "Firm"
                Case 3
                    Word(x) = "Amiable"
                    Definition = "Good-natured"
                Case 4
                    Word(x) = "Amoral"
                    Definition = "Lacking ethical principles"
                Case 5
                    Word(x) = "Animosity"
                    Definition = "Strong dislike"
            End Select

            If x = 1 Then
                If defineNmb = 1 Then
                    pickCorrect.Location = pickWord1.Location
                    Defined.Text = Definition
                End If
                Word1.Text = Word(1)
            ElseIf x = 2
                If defineNmb = 2 Then
                    pickCorrect.Location = pickWord1.Location
                    Defined.Text = Definition
                End If
                Word2.Text = Word(2)
            ElseIf x = 3
                If defineNmb = 3 Then
                    pickCorrect.Location = pickWord1.Location
                    Defined.Text = Definition
                End If
                Word3.Text = Word(3)
            ElseIf x = 4
                If defineNmb = 4 Then
                    pickCorrect.Location = pickWord1.Location
                    Defined.Text = Definition
                End If
                Word4.Text = Word(4)
            End If
        Next x
    End If
End Sub




Aucun commentaire:

Enregistrer un commentaire