Posted By

delm on 04/29/09


Tagged

decimal random aleatorio


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

haoji


Decimal aleatorio


 / Published in: VB.NET
 

Retorna un decimal aleatorio entre un mínimo y un máximo.

  1. Public Shared Function DecimalAleatorio(Optional ByVal maximo As Decimal = Decimal.MaxValue, Optional ByVal minimo As Decimal = Decimal.MinValue) As Decimal
  2. Dim r As New Random()
  3. If minimo > maximo Then
  4. Dim t As Decimal = minimo
  5. minimo = maximo
  6. maximo = t
  7. End If
  8. lastdecimalvalue = (r.NextDouble() * (maximo - minimo)) + minimo
  9. Return lastdecimalvalue

Report this snippet  

You need to login to post a comment.