vb点虐 捕获按键 vb获取窗口按钮
vb点虐 如何用键盘上的回车执行button1的事件
将button1作为窗体的缺省命令按钮吧:
让客户满意是我们工作的目标,不断超越客户的期望值来自于我们对这个行业的热爱。我们立志把好的技术通过有效、简单的方式提供给客户,将通过不懈努力成为客户在信息化领域值得信任、有价值的长期合作伙伴,公司提供的服务项目有:主机域名、网站空间、营销软件、网站建设、汕头网站维护、网站推广。
button1.default=true
如果没有上面这种用法,试试
Me.AcceptButton=button1
利用VB.NET怎样使窗体在没有焦点时也能检测键盘事件?
窗体内检测按键
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.KeyPreview = True '注册窗体的键盘事件
End Sub
在TextBox1中显示按键代码
Private Sub Form1_KeyDown(sender As Object, e As KeyEventArgs) Handles Me.KeyDown
TextBox1.Text = Str(e.KeyCode) + vbCrLf
End Sub
窗体没有焦点,用窗体监测键盘输入缓冲区可以解决,但这似乎可以用于监测用户输入内容,不要用于非法目的呀!所以就是知道也不会告诉你的。
vb点虐 在for循环中如何获取键盘按键
Public Sub TextBox_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs)
Dim SplitStr As String = ","
Dim SelectionStart As Integer = sender.SelectionStart
Dim TextLength As Integer = sender.Text.Length
'------------------------------------------------------------------
Select Case Asc(e.KeyChar)
Case Is = 8 '"回删"
Dim str As String = sender.text
Dim Array = Split(sender.text, ",", -1)
If sender.SelectionStart = str.Length Then
If str.Contains(",") Then
Dim text = ""
For x = 0 To UBound(Array) - 1
If text = "" Then
text += Array(x)
Else
text += "," + Array(x)
End If
Next
sender.text = text
sender.SelectionStart = text.Length
e.KeyChar = Chr(0)
End If
End If
Case Asc("0") To Asc("9") '" 0 to 9 "
e.KeyChar = e.KeyChar
Case Is = 44, 45 '","
Select Case TextLength
Case Is = 0
e.KeyChar = Chr(0)
Case Else
Select Case SelectionStart
Case 0
e.KeyChar = Chr(0)
Case 1 To TextLength - 1
If Mid(sender.text, SelectionStart, 1) = SplitStr Or Mid(sender.text, SelectionStart + 1, 1) = SplitStr Then
e.KeyChar = Chr(0)
Else
e.KeyChar = e.KeyChar
End If
Case TextLength
If Mid(sender.text, SelectionStart, 1) = SplitStr Then
e.KeyChar = Chr(0)
Else
e.KeyChar = e.KeyChar
End If
End Select
End Select
Case Else
e.KeyChar = Chr(0)
End Select
End Sub
这是我的程序中复制过来的,只能输入数据字与逗号还有下划线,你查一下F和J的Ass吗是多少,改写一下就OK
本文名称:vb点虐 捕获按键 vb获取窗口按钮
浏览路径:http://ybzwz.com/article/ddgdoie.html