Decimal aleatorio


/ Published in: VB.NET
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.