sorry to say that the maskedtextbox control in a windows forms for either c# or VB.net is not as flexible as you would hope it to be, it currently allow a fixed width masked value only, as in you will have to type 00002345 to get 23.45 in the textbox. the masked value puts the comma and dot for you so you really don't have to press them.
you can achieve a similar behavior using a regular textbox control by doing the following:
1. Create a textbox control let's call it Textbox1
2. In the code behind add the following:
Private Sub TextBox1_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.GotFocus
If TextBox1.Text = "___,___.__" Then
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
TextBox1.Text = "___,___.__"
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 = "___,___.__" Then
Dim aDecimal As Decimal = CType(TextBox1.Text, Decimal)
TextBox1.Text = Format(aDecimal, "c").Replace("$", "")
End If
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
TextBox1.Text = "___,___.__"
End Sub