I use Visual Basic 2008
I had this code in Visual Basic 6.0 that the replace the ASCII value of decimal point for the ASCII value for a comma

Private Sub Text1_KeyPress(KeyAscii As Integer)
    If KeyAscii = 46 Then KeyAscii =44
End Sub

But this does not work Visual Basic 2008
This I have so far!

Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
       
        If e.KeyCode = Keys.Decimal Then
           
       [B]    'But what code should come here?[/B]

        End If
    End Sub

See if this helps.

Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
        If Asc(e.KeyChar) = 46 Then '// if "dot".
            e.Handled = True '// cancel out the key pressed.
            TextBox1.SelectedText = "- test -" '// replace the selection.
        End If
    End Sub
This question has already been answered. Start a new discussion instead.