How to Choose Random number from given list of numbers in VB.Net

后端 未结 4 601
清酒与你
清酒与你 2021-01-29 03:35

I want to create a random number generator in VB.NET But from my own given list of numbers

Like Chose random numbers fro

4条回答
  •  有刺的猬
    2021-01-29 03:47

    This is how you get a random natural number in the interval of [0, n - 1]:

    CInt(Rnd() * n)
    

    Let's suppose you have a List of n elements. This is how you get a random element from it:

    MyList(CInt(Rnd() * n))
    

提交回复
热议问题