954,541 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Capture keyboard

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
           
       <strong>    'But what code should come here?</strong>

        End If
    End Sub
dre-logics
Junior Poster
106 posts since Aug 2009
Reputation Points: 9
Solved Threads: 0
 

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
codeorder
Posting Virtuoso
1,915 posts since Aug 2010
Reputation Points: 255
Solved Threads: 384
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: