[ Description ("") ]
[ FormDesignerId ("9071B6C7-83BB-4828-B3A6-353AFFBD9C25") ]
[ PredeclaredId ]
Class mfrTerni
    Sub New()
    End Sub
Private Sub Form_Load()
    Label4.Caption = ""
    Label4.Caption = EstrazioneIni & " [" & DataEstrazione(EstrazioneIni) & "]"
    Label5.Caption = ""
    Label5.Caption = EstrazioneFin & " [" & DataEstrazione(EstrazioneFin) & "]"
   
End Sub
Private Sub Command1_Click()
Dim sR As String
Dim idEstr As Long, R As Long, p1 As Long, p2 As Long, p3 As Long, k As Long, k1 As Long, PresMin As Long, max As Long, pres As Long
Dim aStat(88, 89, 90) As Long
Dim aR() As Long
Dim aPresMin() As Variant
Dim t1 As LongLong
aR = ScegliRuote(False)
t1 = Timer
sR = ""
For R = 1 To UBound(aR)
  sR = sR & NomeRuota(aR(R), True) & "."
Next
aPresMin = Array(0, 4, 4, 6, 8, 10, 12, 14, 16, 18, 18, 18)
 PresMin = aPresMin(UBound(aR))
Label6.Caption = RimuoviLastChar(sR, ".")&" "
Label3.Caption = " Terni Vergini"
 Label7.Caption = "Terni con presenza >= " & PresMin
For idEstr = EstrazioneIni To EstrazioneFin
    For R = 1 To UBound(aR)
        ReDim aE(5) As Long
        Call GetArrayNumeriRuota(idEstr, aR(R), aE)
        If aE(1) > 0 Then
        Call OrdinaVettore(aE, 1)
            For p1 = 1 To 3
                For p2 = p1 + 1 To 4
                    For p3 = p2 + 1 To 5
                    aStat(aE(p1), aE(p2), aE(p3)) += 1
                   
                    Next
                Next
            Next
        End If
    Next
Next
For p1 = 1 To 88
    For p2 = p1 + 1 To 89
        For p3 = p2 + 1 To 90
        pres = aStat(p1, p2, p3)
            If aStat(p1, p2, p3) = 0 Then
                k += 1
                List1.AddItem FormatSpace(k, 5) & " | " & Format2(p1) & "." & Format2(p2) & "." & Format2(p3)
            ElseIf aStat(p1, p2, p3) >= PresMin Then
                If max < aStat(p1, p2, p3) Then max = aStat(p1, p2, p3)
                k1 += 1
                List2.AddItem FormatSpace(k1, 5) & " | " & Format2(p1) & "." & Format2(p2) & "." & Format2(p3) & " | " & aStat(p1, p2, p3)
            End If
        Next
    Next
Next
Label8.Caption = "terni vergini Filtrati: " & k
Label9.Caption = "terni Presenza min Filtrati: " & k1 & vbCrLf & "Presenza massima rintracciata:" & max
Label10.Caption = "  Elaborato in " & Round(Timer - t1,2) & " secondi"
End Sub
Function FormatSpace(n As Variant, nChar As Long) As String
Dim L As Long
Dim t As String
t = CStr(n)
L = Len(n)
If L < nChar Then t = Space(nChar - L) & t
Return t
End Function
End Class