VB6 Keyacsii code statement into vb.net????

G

Gary

Hi all, does anyone know what the how to get this vb6 code to work under
vb.net?
I only want to allow digits, backspace and a period to be entered into a
text box.



Private Sub Text13_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 48 To 57 ' Allow digits
Case 8 ' Allow backspace
Case 46 ' Allow period
Case Else
KeyAscii = 0
Beep
End Select
End Sub




Thanks,

Gary
 
S

Shiva

In the KeyPress event of the TextBox, have:

If Not (Char.IsNumber(e.KeyChar) OrElse AscW(e.KeyChar) = 8 OrElse
AscW(e.KeyChar) = 46) Then
e.Handled = True
Else
Beep()
End If

Hi all, does anyone know what the how to get this vb6 code to work under
vb.net?
I only want to allow digits, backspace and a period to be entered into a
text box.



Private Sub Text13_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 48 To 57 ' Allow digits
Case 8 ' Allow backspace
Case 46 ' Allow period
Case Else
KeyAscii = 0
Beep
End Select
End Sub




Thanks,

Gary
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top