
Hai ragione.
Diciamo cosi su 10 caselle ne posso utilizzare solo due e quando seleziono la terza casella dopo il messaggio di errore si deve svuotare.
Penso di esserci riuscito:
codice:
Dim count As Integer = 0
Dim numeroCasellePossibili As Integer = 2
For Each c As Control In Panel1.Controls
If TypeOf c Is System.Windows.Forms.TextBox Then
Dim TXT As System.Windows.Forms.TextBox = DirectCast(c, TextBoxBase)
If Not String.IsNullOrWhiteSpace(TXT.Text) Then
count += 1
End If
End If
Next
If count > numeroCasellePossibili Then
MessageBox.Show("Non è possibile compilare piu' di due caselle!.",vbcritical, "Info Errore")
DirectCast(sender, TextBox).Text = ""
DirectCast(sender, System.Windows.Forms.TextBox).Focus()
End If