Hi, this is murali, Please any one help me to get the code for random genreation of numbers, like to get the recordsin datagrid comes randomly each time i view the output.
Random Generation of numbers
Collapse
X
-
Tags: None
-
Originally posted by y Muralidhar RaoHi, this is murali, Please any one help me to get the code for random genreation of numbers, like to get the recordsin datagrid comes randomly each time i view the output.
You can usefunction which return Random NumbersCode:rnd()
-
If you wanted to generate a random number in between two specific numbers you can use this code
[code=vbnet]
Public Function RandomNumber(By Val MaxNumber As Integer, _
Optional ByVal MinNumber As Integer = 0) As Integer
' Initialize random number generator
Dim r As New Random(System.D ateTime.Now.Mil lisecond)
' If passed incorrect arguments, swap them.
' Can also throw exception or return 0.
If MinNumber > MaxNumber Then
Dim t As Integer = MinNumber
MinNumber = MaxNumber
MaxNumber = t
End If
Return r.Next(MinNumbe r, MaxNumber)
End Function
[/Code]
I haven't tested it yet. This is for vb.net and if you wanted a proper look here is the site
Comment
Comment