是不是有更多的DotNet方法来比较一个角色,看它是否是一个CR。 [英] Isn't there a more DotNet approach to comparing a character to see if it's a CR.?
问题描述
以下是从VB6转换向导的结果。
查看帮助文档我可以找到一个使用Chaw()的例子
如果e.KeyChar = Microsoft.VisualBasic.ChrW(13)那么
e.Handled = True
结束如果
但是没有更多的DotNet方法来比较一个角色,看看它是否是一个CR。
你会怎么做这个?
谢谢
Private Sub ComboBoxFindStr_KeyPress(ByVal ... snip
Dim lKeyAscii作为Short = Asc(e.KeyChar)
''使CR像TAB一样工作
< br $>
System.Windows.Forms.SendKeys.Send(" {TAB}")
lKeyAscii = 0
结束如果
如果lKeyAscii = 0那么
e.Handled = True
结束如果
结束子
Below is the result of the wizard conversion from VB6.
Looking at the Help doc I can find an example that uses Chaw()
If e.KeyChar = Microsoft.VisualBasic.ChrW(13) Then
e.Handled = True
End If
But isn''t there a more DotNet approach to comparing a character to see if
it''s a CR.?
How would you do this?
Thanks
Private Sub ComboBoxFindStr_KeyPress(ByVal ...snip
Dim lKeyAscii As Short = Asc(e.KeyChar)
''make CR work like TAB
If lKeyAscii = 13 Then
System.Windows.Forms.SendKeys.Send("{TAB}")
lKeyAscii = 0
End If
If lKeyAscii = 0 Then
e.Handled = True
End If
End Sub
推荐答案
这个怎么样?
Private Sub ComboBoxFindStr_KeyPress(ByVal ... snip
Dim lKeyAscii As Short = Asc(e.KeyChar)
''让CR像TAB一样工作>
如果lKeyAscii.Equals(13)那么
System.Windows.Forms.SendKeys.Send(" {TAB}")
lKeyAscii = 0
结束如果
''处理的标志是关键是ASCII 0
e.Handled = lKeyAscii.Equals(0)
End Sub
Hows this?
Private Sub ComboBoxFindStr_KeyPress(ByVal ...snip
Dim lKeyAscii As Short = Asc(e.KeyChar)
''make CR work like TAB
If lKeyAscii.Equals(13) Then
System.Windows.Forms.SendKeys.Send("{TAB}")
lKeyAscii = 0
End If
''flag as handled is key is ASCII 0
e.Handled = lKeyAscii.Equals(0)
End Sub
这个怎么样?
Private Sub ComboBoxFindStr_KeyPress(ByVal ... snip
Dim lKeyAscii As Short = Asc(e.KeyChar)
''让CR像TAB一样工作
如果lKeyAscii.Equals(13)那么
System.Windows.Forms.SendKeys.Send(" {TAB}")
lKeyAscii = 0
结束如果
''处理的标志是关键是ASCII 0
e.Handled = lKeyAscii.Equals( 0)
结束子
Hows this?
Private Sub ComboBoxFindStr_KeyPress(ByVal ...snip
Dim lKeyAscii As Short = Asc(e.KeyChar)
''make CR work like TAB
If lKeyAscii.Equals(13) Then
System.Windows.Forms.SendKeys.Send("{TAB}")
lKeyAscii = 0
End If
''flag as handled is key is ASCII 0
e.Handled = lKeyAscii.Equals(0)
End Sub
JM
那里很多,但对我来说这是(没有命名空间)最好的
dotNet一个。
Cor
JM
There are a lot, however for me is this (without the namespace) the nicest
dotNet one.
Cor
这篇关于是不是有更多的DotNet方法来比较一个角色,看它是否是一个CR。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!