Option Explicit
Private Sub chkNumero_Click()
txtNumero.Enabled = CBool(chkNumero.Value)
End Sub
Private Sub cmdCambia_Click()
On Error GoTo Errore
CDialog.ShowOpen
txtXCorso.Text = CDialog.FileName
Exit Sub
Errore:
MsgBox "Errore numero: " & Err.Number & vbCrLf & Err.Description, vbCritical
txtXCorso.Text = ""
End Sub
Private Sub cmdCerca_Click()
On Error GoTo Errore
Dim File As Integer
Dim Parola As String
txtRima = Replace(LCase(txtRima), " ", "")
If txtRima.Text <> "" Then
lstRime.Clear
File = FreeFile
Open txtXCorso.Text For Input As File
Do While EOF(File) = 0
Input #File, Parola
If CBool(chkNumero.Value) = False Then
If optFine.Value = True And Right(Parola, Len(txtRima)) = txtRima Then lstRime.AddItem Parola
If optFine.Value = False And Left(Parola, Len(txtRima)) = txtRima Then lstRime.AddItem Parola
ElseIf CBool(chkNumero.Value) = True Then
If optFine.Value = True And Right(Parola, txtNumero) = Right(txtRima, txtNumero) Then lstRime.AddItem Parola
If optFine.Value = False And Left(Parola, txtNumero) = Left(txtRima, txtNumero) Then lstRime.AddItem Parola
End If
Loop
Close #File
lblStato.Caption = "Risultati trovati: " & lstRime.ListCount
End If
Exit Sub
Errore:
MsgBox "Errore numero: " & Err.Number & vbCrLf & Err.Description, vbCritical
End Sub
Private Sub Form_Load()
txtXCorso.Text = App.Path & "\italiano.txt"
CDialog.FileName = txtXCorso
chkNumero_Click
End Sub