'
'rif. 0902_83a Ro - Ripetuti sul quadro esteso - a ruota, scegliere la frequenza + bassa 
Option Explicit
Sub Main()
	
	'visualizza il quadro esteso con colorazione dei numeri ripetuti nella frequenza scelta e nelle successive +1, +2 e +3 per aver un quadro di lettura più ampio
	Dim Vet(),stat(),temp(),nu(),max(12)
	Dim fin,estr,Ini,r,es,f1,f2,f3,f4,n,p,x,y,i,cu,maxcu,co,riga,rigo,t,u,cl,m,s
	Dim sTmpRiga,nTmpColor
	
	
	fin = EstrazioneFin -(InputBox("Quante es vuoi andare indietro rispetto a Estrazionefin?",,5))
	estr = InputBox("Su quante estrazioni vuoi cercare i ripetuti?",,12)
	f1 = CInt(InputBox("Quale frequenza devono avere i ripetuti?","Frequenza più bassa",2)) 'se vuoi con freq maggiori metti l'apice
	' davanti a f e sostituisci la riga dove tovi questo segno<<<<<<<<<<<<<<<
	'f2 = CInt(InputBox("Quale frequenza devono avere i ripetuti?",,f1+1)) 
	'f3 = CInt(InputBox("Quale frequenza devono avere i ripetuti?",,f1+2)) 
	'f4 = CInt(InputBox("Quale frequenza devono avere i ripetuti?",,f1+3)) 
	
	f2 = f1+1 
	f3 = f1+2 
	f4 = f1+3
		
	Ini = fin -(estr - 1)
	ReDim vet(0)
	ReDim stat(2,0)
	ReDim temp(0)
	ReDim nu(12,0)
	For r = 1 To 12
		If r <> 11 Then nu(r,0) = r
	Next
	'-----------------------------
	For r = 1 To 11
		If r = 11 Then r = 12
		Erase vet
		Erase stat
		ReDim vet(estr*5)
		n = 0
		For es = Ini To fin
			For p = 1 To 5
				n = n + 1
				vet(n) = Estratto(es,r,p)
			Next
		Next
		'------------------------
		OrdinaMatrice vet,1
		x = UBound(vet)
		ReDim stat(2,0)
		For i = 1 To x
			If vet(i) > vet(i - 1) Then
				co = co + 1
				ReDim Preserve stat(2,co)
				stat(1,co) = vet(i)
				stat(2,co) = 1
				For y = i + 1 To x
					If vet(i) = vet(y) Then stat(2,co) = stat(2,co) + 1
				Next
			End If
		Next
		'------------------------
		cu = 0
		ReDim temp(0)
		For i = 1 To co
			If stat(2,i) = f1 Then ' <<<<<<<<<< sostituisci con questa If stat(2,i)=> 2 Then ''sostituito il 2 con f
			cu = cu + 1
			ReDim Preserve temp(cu)
			If cu > maxcu Then maxcu = cu
			temp(cu) = stat(1,i)
		End If
	Next
	max(r) = cu
	ReDim Preserve nu(12,maxcu)
	For i = 1 To cu
		nu(r,i) = temp(i)
	Next
Next
'--------------------------------------
ColoreTesto 0
Scrivi Chr(10) & " QUADRO ESTESO DEI NUMERI RIPETUTI ",1,0
ColoreTesto 2
Scrivi "--> " & f1 & " <-- ",1,0
ColoreTesto 0
Scrivi " VOLTE SU RUOTA UNICA " & Chr(10),1
Scrivi Space(4) & "Ru - Ripetuti ",1
riga = FormattaTesto("Data",Space(10),2)
For r = 1 To 12
	'If max(r) > 0 Then riga = riga & Space(6) & SiglaRuota(r) & Space(7)
	If max(r) > 0 Then riga = riga & FormattaTesto(SiglaRuota(r),Space(15),2)
	rigo = ""
	If max(r) > 0 Then
		rigo = Space(4) & SiglaRuota(nu(r,0)) & Space(2)
		For t = 1 To max(r)
			rigo = rigo & " " & Format2(nu(r,t))
		Next
		u = u + 1
	End If
	If rigo <> "" Then Scrivi rigo
Next
If u > 0 Then
	
	Scrivi
	Scrivi riga,1
	For es = Ini To fin
		'ColoreTesto 0
		
		'Call Scrivi(DataEstrazione(es),0,0)
		
		sTmpRiga = DataEstrazione(es)
		
		For r = 1 To 11
			If r = 11 Then
				r = 12
			End If
			If max(r) > 0 Then
				'ColoreTesto 0
				'Scrivi "|",0,0
				sTmpRiga = sTmpRiga & "|"
				If Not pari(r) Or r = 12 Then
					cl = "#FF0000" ' rosso
				Else
					cl = "#0000FF" ' blue
				End If
				For p = 1 To 5
					For m = 1 To max(r)
						'ColoreTesto 0
						nTmpColor = "#000000"
						If Estratto(es,r,p) = nu(r,m) Then
							'ColoreTesto cl
							nTmpColor = cl
							Exit For
						End If
					Next
					If p < 5 Then s = " " Else s = ""
					sTmpRiga = sTmpRiga & GetTestoColorato(Format2(Estratto(es,r,p)),nTmpColor) & s
					'Call Scrivi(Format2(Estratto(es,r,p)) & s,1,0)
				Next
				'If r = 12 And p = 6 Or r = u And p = 6 Then Scrivi Chr(13)
				'If r = 12 And p = 6  Then Scrivi Chr(13)
			End If
		Next
		Call Scrivi(sTmpRiga)
		
	Next
En