TextBox_KeyPress事件 [英] TextBox_KeyPress event

查看:84
本文介绍了TextBox_KeyPress事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时拦截键盘输入并对

采取一些操作实际条目以使其更有用等等是有用的。等如何复制

功能以下VB6代码到VB.Net 2005代码? (如果您在txtAccountNumber中输入
或U,而不是u或U,则会出现1。)


Private Sub txtAccountNumber_KeyPress(KeyAscii As Integer)

Select Case KeyAscii

Case 85''U,更改为1

KeyAscii = 49

案例117''你,改为1

KeyAscii = 49

Case Else

''什么都不做,全部除了你或你以外的入境是好的

结束选择

结束子


谢谢,John Brown

-

John Brown

解决方案

" John Brown" < jo ******* @ discussion.microsoft.comschrieb


有时截取键盘输入并采取一些
$ b $非常有用b对实际条目的操作使其更有用,等等。我如何将
复制以下VB6代码的功能到VB.Net 2005

代码? (如果您在txtAccountNumber中输入u或U,而不是u或

" U",则会出现1。)


Private Sub txtAccountNumber_KeyPress(KeyAscii As Integer)

Select Case KeyAscii

Case 85''U,更改为1

KeyAscii = 49

案例117''你,改为1

KeyAscii = 49

Case Else

''什么都不做,全部除U或U之外的条目是好的

结束选择

结束Sub



私有子TextBox1_KeyPress(_

ByVal发送者作为对象,_

ByVal e As System.Windows.Forms.KeyPressEventArgs)_

处理TextBox1.KeyPress


选择案例e.KeyChar

案例Uc,uc

e.KeyChar =" 1" c

结束选择


结束子

Armin


你好,


" Armin Zingler" < az ******* @ bernett的freenet.deschreef

新闻:************** @ TK2MSFTNGP05.phx.gbl ...


Private Sub TextBox1_KeyPress(_

ByVal sender As Object,_

ByVal e As System.Windows。 Forms.KeyPressEventArgs)_

处理TextBox1.KeyPress


选择案例e.KeyChar

案例Uc," ; u" c

e.KeyChar =" 1" c

结束选择


结束子



我想知道,在U,u之后''c''的含义是什么?和1?


谢谢,

米歇尔


" ; Michel Vanderbeke < mi *************** @ skynet.beschrieb


您好,


Armin Zingler < az ******* @ bernett的freenet.deschreef

新闻:************** @ TK2MSFTNGP05.phx.gbl ...


Private Sub TextBox1_KeyPress(_

ByVal sender As Object,_

ByVal e As System.Windows。 Forms.KeyPressEventArgs)_句柄

TextBox1.KeyPress


选择案例e.KeyChar

案例Uc," ; u" c

e.KeyChar =" 1" c

结束选择


结束子



我想知道,在U,u之后''c''的含义是什么?和1?



这是确定字符(Char)字面值的后缀。

http://msdn2.microsoft.com/en-us/lib...ek(VS。 71).aspx


我已经在语言规范中查找了链接但是在MSDN lib中

TOC它是'只有vor VS 2003:
http://msdn2.microsoft.com/en-us/lib...ek(VS.71).aspx


对于VB 2005,它可以可在此下载:
http ://msdn2.microsoft.com/en-us/lib...37(VS.80).aspx

Armin


Sometimes it is useful to intercept keyboard entry and take some action on
the actual entry to make it more useful, etc. How do I duplicate the
functionality of the following VB6 code to VB.Net 2005 code? (if you enter u
or U in txtAccountNumber, rather than a "u" or "U", a "1" appears.)

Private Sub txtAccountNumber_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 85 ''U, change to 1
KeyAscii = 49
Case 117 ''u, change to 1
KeyAscii = 49
Case Else
'' do nothing, all entry except U or u is OK
End Select
End Sub

Thanks, John Brown
--
John Brown

解决方案

"John Brown" <Jo*******@discussions.microsoft.comschrieb

Sometimes it is useful to intercept keyboard entry and take some
action on the actual entry to make it more useful, etc. How do I
duplicate the functionality of the following VB6 code to VB.Net 2005
code? (if you enter u or U in txtAccountNumber, rather than a "u" or
"U", a "1" appears.)

Private Sub txtAccountNumber_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 85 ''U, change to 1
KeyAscii = 49
Case 117 ''u, change to 1
KeyAscii = 49
Case Else
'' do nothing, all entry except U or u is OK
End Select
End Sub


Private Sub TextBox1_KeyPress( _
ByVal sender As Object, _
ByVal e As System.Windows.Forms.KeyPressEventArgs) _
Handles TextBox1.KeyPress

Select Case e.KeyChar
Case "U"c, "u"c
e.KeyChar = "1"c
End Select

End Sub
Armin


Hello,

"Armin Zingler" <az*******@freenet.deschreef in bericht
news:Of**************@TK2MSFTNGP05.phx.gbl...

Private Sub TextBox1_KeyPress( _
ByVal sender As Object, _
ByVal e As System.Windows.Forms.KeyPressEventArgs) _
Handles TextBox1.KeyPress

Select Case e.KeyChar
Case "U"c, "u"c
e.KeyChar = "1"c
End Select

End Sub

I wondered, what is the meaning of the ''c'' after "U", "u" and "1"?

Thank you,

Michel


"Michel Vanderbeke" <mi***************@skynet.beschrieb

Hello,

"Armin Zingler" <az*******@freenet.deschreef in bericht
news:Of**************@TK2MSFTNGP05.phx.gbl...

Private Sub TextBox1_KeyPress( _
ByVal sender As Object, _
ByVal e As System.Windows.Forms.KeyPressEventArgs) _ Handles
TextBox1.KeyPress

Select Case e.KeyChar
Case "U"c, "u"c
e.KeyChar = "1"c
End Select

End Sub


I wondered, what is the meaning of the ''c'' after "U", "u" and "1"?


It''s a suffix determining a character (Char) literal.

http://msdn2.microsoft.com/en-us/lib...ek(VS.71).aspx

I''ve looked for the link in the language specification but in the MSDN lib
TOC it''s only still there vor VS 2003:
http://msdn2.microsoft.com/en-us/lib...ek(VS.71).aspx

For VB 2005, it can be downloaded here:
http://msdn2.microsoft.com/en-us/lib...37(VS.80).aspx
Armin


这篇关于TextBox_KeyPress事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆