本文介绍了Vb.Net:如何生成随机nuber,不包括previos generaded?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Vb.Net:如何生成随机nuber,不包括previos generaded ???

Vb.Net: how to generate random nuber, not including previos generaded???

推荐答案


Dim valueRnd As String = ""
Dim ballCnt As Single = 0
Dim gotcha As Boolean = False
Dim z As Single = 0
Dim Xy As Single

For Xy = 0 To 75    'Function BallList
    aryRnd(Xy) = 0
Next (Xy)

Do While ballCnt <= 74
    gotcha = False

    ' Initialize the random-number generator.
    Randomize()

    '      Generate random value between 1 and 75.
    valueRnd = CInt(Int((75 * Rnd()) + 1))

    '    Check for existence of the number in the array
    For Xy = 1 To ballCnt + 1
        If aryRnd(Xy) = valueRnd Then
            gotcha = True
            Exit For
        End If
    Next Xy

    '   Add to array if not found
    If Not gotcha Then
        aryRnd(ballCnt + 1) = valueRnd
        ballCnt = ballCnt + 1
    End If
Loop


这篇关于Vb.Net:如何生成随机nuber,不包括previos generaded?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-21 16:57