By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,694 Members | 1,795 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,694 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Jul 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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

"Gary" <sp**@spam.net.at> wrote in message
news:Mj******************@news-server.bigpond.net.au...
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

Jul 21 '05 #2

P: n/a
Thanks for that :-)

Gary
"Shiva" <sh******@online.excite.com> wrote in message
news:OJ**************@tk2msftngp13.phx.gbl...
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

"Gary" <sp**@spam.net.at> wrote in message
news:Mj******************@news-server.bigpond.net.au...
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

Jul 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.