VB Code:
Private Sub testi(ByRef casella As TextBox, ByVal car As Char, ByRef bool As Boolean)
If (casella.Text.IndexOf(",") >= 0 And car = ",") Then bool = True
If (Char.IsDigit(car) Or car = "," Or Char.IsControl(car)) = False Then
bool = True
End If
If (casella.Text.IndexOf(",") > 0 And Char.IsControl(car) = False) Then
If casella.Text.Substring(casella.Text.IndexOf(",")).Length > 2 Then
bool = True
End If
End If
End Sub
VB Code:
Private Sub txbEuro1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txbEuro1.KeyPress
Me.testi(txbEuro1, e.KeyChar, e.Handled)
End Sub