codice:Private Sub Command2_Click() Dim err1 As String Dim k As Long Dim z As Long Dim q As Integer Dim righe As Long Dim values(2) As String Dim a As Long Dim b As Long Dim c As Long Dim somma As Single Dim prova As String Dim prova2 As String Dim perc As Single Dim perc2 As Single Dim app(2) As Single Dim parcheggio(1) As Single Dim lastr As Single Dim ris As Single Dim div As Long Dim segno As Integer If (Combo1.Text = "13") Then baseordin = False Else baseordin = True End If For i = 0 To 13 tec(i, 0) = Val(unot(i).Text) tec(i, 1) = Val(icst(i).Text) tec(i, 2) = Val(duet(i).Text) gioc(i, 0) = Val(unog(i).Text) gioc(i, 1) = Val(icsg(i).Text) gioc(i, 2) = Val(dueg(i).Text) Next i For i = 0 To 13 If (tec(i, 0) = 0 Or tec(i, 1) = 0 Or tec(i, 2) = 0) Then err1 = "Non è stato inserito uno o più dati nel picchetto tecnico." End If If (gioc(i, 0) = 0 Or gioc(i, 1) = 0 Or gioc(i, 2) = 0) Then If (err1 <> "") Then err1 = err1 & " Non è stato inserito uno o più dati nel picchetto giocato." Else err1 = "Non è stato inserito uno o più dati nel picchetto giocato." End If End If Next i If (err1 <> "") Then MsgBox err1 & " Impossibile proseguire!", vbInformation Else prob(0, 0) = 0 prob(0, 1) = 1 prob(0, 2) = 1 righe = 1 For i = 0 To 13 prob(0, 1) = prob(0, 1) * (tec(i, 0) / 100) prob(0, 2) = prob(0, 2) * (gioc(i, 0) / 100) If (i = 8) Then prob(0, 4) = prob(0, 1) / prob(0, 2) End If Next i prob(0, 3) = prob(0, 1) / prob(0, 2) For k = 0 To 13 For z = 1 To 2 For i = 0 To righe - 1 prob(i + (righe * z), 0) = i + (righe * z) prob(i + (righe * z), 1) = (prob(i, 1) / (tec(k, 0) / 100)) * (tec(k, z) / 100) prob(i + (righe * z), 2) = (prob(i, 2) / (gioc(k, 0) / 100)) * (gioc(k, z) / 100) If (righe < 19683) Then prob(i + (righe * z), 4) = (prob(i, 4) / ((tec(k, 0) / 100) / (gioc(k, 0) / 100))) * ((tec(k, z) / 100) / (gioc(k, z) / 100)) Else prob(i + (righe * z), 4) = prob(i, 4) End If Next i Next z If (righe <> 4782969) Then righe = righe * 3 End If Next k For i = 0 To 4782968 c = 1 For k = 0 To 13 If (k > 0) Then c = c * 3 End If ris = prob(i, 0) / c If (ris > 3) Then ris = ris - (Int(ris / 3) * 3) End If If (ris < 1) Then segno = 0 Else If (ris < 2) Then segno = 1 Else segno = 2 End If End If prob(i, 5) = prob(i, 5) + ((prob(i, 1) / (tec(k, segno) / 100)) * (1 - (tec(k, segno) / 100))) prob(i, 6) = prob(i, 6) + ((prob(i, 2) / (gioc(k, segno) / 100)) * (1 - (gioc(k, segno) / 100))) If (baseordin = True) Then prob(i, 3) = prob(i, 1) / prob(i, 2) Else prob(i, 3) = prob(i, 5) / prob(i, 6) End If Next k Next i MergeSort prob, 0, 4782968 For i = 0 To 9 p(i) = prob(i, 1) & " " & prob(i, 2) Next i ordinamento.Show dati.Hide sviluppo.Hide Unload costo Unload montepremi Unload apri Unload analisi End If End Sub