Option Explicit
Public Parola As String
Public Nuova As Boolean
Private Sub Ricomincia()
Nuova = True
Unload Me
frmMain.Show
End Sub
Private Sub GameOver()
If MsgBox("HAI PERSO" & vbCrLf & "La parola da scoprire era: " & Parola & vbCrLf & "Vuoi Iniziare una nuova partita?", vbYesNo + vbQuestion) = vbNo Then
End
Else
Ricomincia
End If
End Sub
Private Sub Sostituisci(Lettera As String)
Dim I As Integer
Dim Word As String
Dim BoolTent As Boolean
For I = 1 To Len(Parola)
If Mid(Parola, I, 1) = Lettera Then
lblLettera(I - 1).Caption = Lettera
BoolTent = True
End If
Word = Word & lblLettera(I - 1).Caption
If Word = Parola Then
If MsgBox("HAI VINTO" & vbCrLf & "Vuoi Iniziare una nuova partita?", vbQuestion + vbYesNo) = vbYes Then
Ricomincia
Else
End
End If
End If
Next I
If BoolTent = False Then
If lblTentativi.Caption = 7 Then
shpTesta.Visible = True
Else
lnCorpo(6 - lblTentativi.Caption).Visible = True
End If
lblTentativi.Caption = lblTentativi.Caption - 1
End If
If lblTentativi.Caption = "0" Then GameOver
End Sub
Private Sub cmdLettera_Click(Index As Integer)
cmdLettera(Index).Enabled = False
Sostituisci (Replace(cmdLettera(Index).Caption, "&", ""))
End Sub
Private Sub cmdRese_Click()
If MsgBox("Sicuro di volerti arrendere?", vbQuestion + vbYesNo) = vbYes Then GameOver
End Sub
Private Sub Form_Load()
Dim I As Integer
Parola = frmMain.Parola
Me.Width = 7545
lblLunghezza.Caption = Len(Parola)
shpTesta.Visible = False
For I = 0 To 25
cmdLettera(I).Caption = "&" & Chr(Asc("A") + I)
If I < 6 Then lnCorpo(I).Visible = False
Next I
For I = 1 To Len(Parola) - 1
Load lblLettera(I)
lblLettera(I).Left = lblLettera(I - 1).Left + lblLettera(I).Width + 120
lblLettera(I).Visible = True
Next I
If Me.Width < lblLettera(I - 1).Left + 120 * 3 + lblLettera(I - 1).Width Then Me.Width = lblLettera(I - 1).Left + 120 * 3 + lblLettera(I - 1).Width
Nuova = False
End Sub
Private Sub Form_Unload(Cancel As Integer)
If Nuova = False Then If MsgBox("Sicuro di voler uscire?", vbQuestion + vbYesNo) = vbNo Then Cancel = 1
End Sub