| 

.NET C# Java Javascript Exception

1
Textbox intelligent formatieren!

Hat einer eine weitere Idee zur Textboxen Formatierung - Mask (ohne Maskbox)

Code Verbesserungs würdig!

'################ Textboxen formatieren und focus setzen und nur Zahlen eingeben
Private Sub TextBox1_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.GotFocus
If TextBox1.Text = "0,00" Then
'Entfernt die Maske, sobald sich der Mauszeiger im Textbox
TextBox1.Text = ""
End If
End Sub
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
Dim ListofChars As String = "0123456789.,"
If ListofChars.IndexOf(e.KeyChar) = -1 Then
e.Handled = True
End If
End Sub
Private Sub TextBox1_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.LostFocus
If TextBox1.Text = "" Then
'Setzt die Maske zurück, wenn Sie nichts in das Textfeld eingegeben haben, sobald der Mauszeiger das Textfeld verlassen hat
TextBox1.Text = "0,00"
End If
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
TextBox1.Text = TextBox1.Text.Trim
If Not TextBox1.Text = "" And Not TextBox1.Text = "0,00" Then
'Dim aDecimal As Decimal = CType(TextBox1.Text, Decimal)
Dim aDouble As Double = CType(TextBox1.Text, Double)
'TextBox1.Text = Format(aDecimal, "c").Replace("$", "")
TextBox1.Text = Format([aDouble], "c").Replace("$", "")

'TextBox1.Text = Format(Double.Parse(TextBox1.Text), "########0.00")

'Dim texto As String = TextBox1.Text
'TextBox1.Text = String.Format("{0:0,0}", Val(Replace(aDouble, ",", ".")))
End If
End Sub

Form

'---------- Textboxen 1 - 6 - 11 formatieren
TextBox1.Text = "0,00"
20.07.2020
tsmeier 51 1 3