RSS Feed

Syndicate content

si può usare la funzione CASUALE TRA con un range di numeri specifici non progressivi e non ripetitivi Se non è possibile ci sono alternative?

Submitted by Anonimo on Fri, 03/09/2010 - 14:09

Sembra una tipica richiesta di numero casuale non ricorrente, tipico di estrazione senza reimbussulamento.

Un esempio è l'estrazione dei numeri del lotto. Puoi trovare esempi a bizzeffe con una semplice ricerca su internet. Ne riporto qui una per semplicità:

Function RandLotto(Bottom As Integer, Top As Integer, _ Amount As Integer) As String Dim iArr As Variant Dim i As Integer Dim r As Integer Dim temp As Integer Application.Volatile ReDim iArr(Bottom To Top) For i = Bottom To Top iArr(i) = i Next i For i = Top To Bottom + 1 Step -1 r = Int(Rnd() * (i - Bottom + 1)) + Bottom temp = iArr(r) iArr(r) = iArr(i) iArr(i) = temp Next i For i = Bottom To Bottom + Amount - 1 RandLotto = RandLotto & " " & iArr(i) Next i RandLotto = Trim(RandLotto) End Function

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <style> <center> <p>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.

Custom Search