A1VBCode Forums

VB.net code...CPU time scheduler (shortest job first)


http://a1vbcode.com/vbforums/Topic25007.aspx

By charliemears - 5/26/2008



I really need VB.Net code for this...

How can I generate a random number?



I will use this code for my project on CPU time scheduling which is Shortest Job First(SJF)...

any idea about this? or any useful source where can I get this program or code?

or

you can share a code or a hint....



many many thanks for any reply....








By cr4sh09 - 5/26/2008

If you need nonrepeating random numbers, you could write your code like this:

Dim arrNum(1 To 100) As Integer       '1 Being the lowest random number, 100 being the highest
Dim intNum As Integer
Dim y As Integer
Dim z As Integer
  Start:
    Randomize()
    intNum = Int((99 * Rnd()) + 1)    'Number range 1-100
      For y = 1 To 100                'Number of different random numbers you need
        If intNum = arrNum(z) Then    'Checks the random number to the array for repeats
      GoTo Start                      'Repeats are ignored and a new random number is generated
    End If
      arrNum(x) = intNum              'Adds the random number to an array
    Next y
Exit Sub
End Sub
End
Class

 

But if you simply just want random numbers, you could write your code like this:

Dim Value As Object
  Randomize()
    Value = Int(100 * Rnd())     
'Gives a random number between 1 - 100

 

Hope this helps you.