Thursday 17 January 2013

Unique Random number generator in vb.net

//hey guys here is my new program in vb.NET which generates unique 20 random Numbers.
Public Class Form1
    Dim generator As New Random
    Dim arr(20) As Integer
    Dim num As Integer = 0
    Dim i As Integer = 1
    Dim k As Integer = 0
    Dim x As Boolean

    Public Sub btngenerate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btngenerate.Click

        numshow()


    End Sub


    Private Sub numshow()
        If k < 20 Then
            num = generator.Next(1, 21)
            x = check()
            If x = True Then

                arr(i) = num
                Label1.Text = arr(i).ToString
                i = i + 1
                k = k + 1
            Else

                numshow()
                num = 0
            End If


        Else
            MessageBox.Show("no more")
        End If

    End Sub
    Private Function check() As Boolean
        Dim l = i - 1
        For j As Integer = 1 To l

            If arr(j) = num Then
                Return False
            End If
        Next
        Return True

    End Function
End Class



If you liked the code please do the courtesy to give one like and follow my blog or please at least visit our youtube channel at least once and subscribe that too if you like.
Click here to visit youtube channel

2 comments:

  1. Far Cry 4 Gameplay series .......
    https://www.youtube.com/watch?feature=player_detailpage&v=88V4E1-nbqo

    ReplyDelete
  2. It’s always a pleasure to see you! Get the best help with writing papers for high school on expert writers review. We also work with college and university assignments. Order any type of essay or research paper you want, and we’ll do it within the agreed period of time. Since 2020, we haven't had a single missed deadline that prevented a student from handing in a paper timely.

    ReplyDelete