提前祝:新春增福纳贤。VB创建随机数

前端之家收集整理的这篇文章主要介绍了提前祝:新春增福纳贤。VB创建随机数前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。


VB创建随机

Module Module1

    Sub Main()
开始位置:
        Dim 步进 = New Random().Next(10),计数 = 4
        Do
            For 序 As Integer = 1 To 20 * 步进 Step 步进
                Console.WriteLine("生成随机数字{0}",New Random(序).Next(1,序 * 3))
                If 序 Mod 10 = 0 Then
                    序 = 0
                    Console.WriteLine()
                End If
            Next
            步进 += New Random().Next(10)
            计数 -= 1
        Loop While (计数 > 0)
        
'Dim 数组()
        '数组 = {"李欢","龚丽","谭显亮","王涛","徐荣辉","刘烨","郑权恒","廖伟","郭威","李襑"}
        'Dim 随机 = New Random().Next(数组.Count)
        'Do
        '    If 数组(随机) <> "" Then
        '        计数 -= 1
        '        Me.Text = 数组(随机) & 计数
        '        数组(随机) = ""
        '        Exit Do
        '    Else
        '        随机 = New Random().Next(数组.Count)
        '    End If
        'Loop While (计数 > 0)

        Console.ReadLine()
        GoTo 开始位置
    End Sub

    随机数组()

End Module

    Public Sub 随机数组()
        Dim arry(9) As Integer
        Dim num As Integer
        Dim i As Integer
        Randomize()
        For i = 0 To 9
            num = (Rnd() * 1000000 Mod 51) + 1
            If arry.Contains(num) Then
                i -= 1
            Else
                arry(i) = num
            End If
        Next
        Console.WriteLine(String.Join("-",arry))
    End Sub

原文链接:https://www.f2er.com/vb/257569.html

猜你在找的VB相关文章