none
为什么这段代码生成的随机数都是重复的呢?哪位高手指点一下!谢谢! RRS feed

  • 问题

  • Private Sub kaishi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kaishi.Click
            '此段代码产生随机数
            Dim suzulist() As Integer = New Integer(5) {}

            For i As Integer = 0 To 5

    xunh:       Randomize()
                a = CInt(Int((33) * Rnd() + 1))

                If a = Array.IndexOf(suzulist, a) Then
                    GoTo xunh
                End If

                suzulist(i) = a
            Next i
            TextBox1.Text = suzulist(0)
            TextBox2.Text = suzulist(1)
            TextBox3.Text = suzulist(2)
            TextBox4.Text = suzulist(3)
            TextBox5.Text = suzulist(4)
            TextBox6.Text = suzulist(5)
        End Sub

    2012年7月15日 2:40

答案

全部回复