mercredi 22 novembre 2017

Has random have a limit?

Im working on a program which generating random numbers. I have use random in generating the build number. I just wondering does random will have a limit? heres my code thank you in advance.

 Private Sub agenerate_Click(sender As Object, e As EventArgs) Handles agenerate.Click
    Dim rand As New Random
    abuildnumber.Text = rand.Next
    Dim exist As String = String.Empty
    exist &= "select * from stocks "
    exist &= "where build_number=@build"
    Using conn As New SqlConnection("server=WIN10;user=admin;password=12345;database=pc_parts")
        Using cmd As New SqlCommand
            With cmd
                .Connection = conn
                .CommandType = CommandType.Text
                .CommandText = exist
                .Parameters.AddWithValue("@build", abuildnumber.Text)
            End With
            Try
                conn.Open()
                Dim reader As SqlDataReader = cmd.ExecuteReader
                If reader.HasRows Then
                    reader.Close()
                    abuildnumber.Text = rand.Next
                End If
                abrand.Enabled = True
                apart.Enabled = True
                aquantity.Enabled = True
                aday.Enabled = True
                amonth.Enabled = True
                ayear.Enabled = True
                add.Enabled = True
                conn.Close()
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
        End Using
    End Using
End Sub




Aucun commentaire:

Enregistrer un commentaire