Option Explicit
Sub Main
   Dim Fin,Ini,Es,R1,X,Caso,Casi
   Dim Somma,Somma_F90,Som,Clp
   Dim Num(2),Ru(1),Posta(2)
   Posta(1) = 1
   Posta(2) = 1
   Fin = EstrazioneFin
   Ini = InputBox("Inserisci l'estrazione che vuoi iniziare",,10000)
   Som = CInt(InputBox("Qual è la somma Fuori90 della cinquina?",,40))
   Clp = CInt(InputBox("Quanti colpi di gioco?",,12))
   Call ScegliRange(Ini,Fin,Ini,Fin)
   Scrivi Space(1) & " Chiesto da Matematico - Ricerca delle cinquine con una somma a scelta - Script Salvo50",1,,4,,3,,1
   Scrivi Space(7) & " Con Scomposizione Somma Dei Cinque estratti in 2 numeri - Script Salvo50" & Space(7),1,,4,,3,,1
    For Es = Ini To Fin
   AvanzamentoElab Ini,Fin,Es
   For R1 = 1 To 12
      If R1 = 11 Then R1 = 12
      Somma = SommaEstratti(Es,R1)
      Somma_F90 = Fuori90(Somma)
      If Somma_F90 = Som Then
         If Somma > 99 Then X = Right(Somma,1)
         If((Somma > 99) And(X <> 0)) Or(Somma < 91) Or(X = 0)Then
            If(Somma > 99) And(X <> 0) Then
               Num(1) = Left(Somma,2)
               Num(2) = Right(Somma,1)
            End If
            If Somma < 91 Then
               Num(1) = Somma
               Num(2) = Vert(Somma)
            End If
            If X = 0 Then
               Num(1) = Left(Somma,2)
               Num(2) = Vert(Num(1))
            End If
            Casi = Casi + 1
            If Casi = 1 Then
               Scrivi
               Scrivi Space(30) & "La Somma scelta è " & Format2(Som),1,,,,3
               Scrivi
            End If
            Scrivi String(90,"*") & " Casi Totali " & FormattaStringa(Casi,"00000"),,,,1
            Scrivi(" Estrazione n." & FormattaStringa(Es,"00000") & " del " & DataEstrazione(Es)),1,0
            Scrivi "  " & SiglaRuota(R1) & " " & StringaEstratti(Es,R1),1,0
            Scrivi " Somma Estratti ",1,0
            Scrivi Format2(Somma),1,0,,2
            Scrivi " Col Fuori90 ",1,0
            Scrivi Format2(Somma_F90),1,,,2
            Scrivi
            Ru(1) = R1
            ImpostaGiocata 1,Num,Ru,Posta,Clp
            Gioca Es,1,,1
         End If
      End If
   Next
   If ScriptInterrotto Then Exit Sub
   '
Next
ScriviResoconto
End Sub