label控件连个焦点都没有呢 你可以用一个commandbutton控件并设置caption 为 "&User:",然后用下面的代码: private sub command1_click() usrTxt.setfocus end sub 那么用户按Alt+U时,usrTxt就得到焦点
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyF5 Then usrTxt.SetFocus End If End Sub热键没试过 学习一下
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) If Shift = 4 And LCase(Chr(KeyCode)) = "u" Then usrTxt.SetFocus End If End SubPrivate Sub Form_Load() Me.KeyPreview = True End Sub
你可以用一个commandbutton控件并设置caption 为 "&User:",然后用下面的代码:
private sub command1_click()
usrTxt.setfocus
end sub
那么用户按Alt+U时,usrTxt就得到焦点
If KeyCode = vbKeyF5 Then
usrTxt.SetFocus
End If
End Sub热键没试过 学习一下
If Shift = 4 And LCase(Chr(KeyCode)) = "u" Then
usrTxt.SetFocus
End If
End SubPrivate Sub Form_Load()
Me.KeyPreview = True
End Sub
我不想用代码实现……
可以参看VB添加窗体(Add Form)--> 登陆对话框(Login Dialog)
我看了半天也没有看出其中的窍门来……所以来请教大家
>我已经为Label设置caption 为 "&User:"
>请问如何才能让用户按Alt+U时,usrTxt得到焦点?你说的 usrTxt 是不是一个 Textbox ?
如果是,那么你直接将 label 的caption 设为 &即可
但还有一项需要设置设置 TabIndex 例如将label 的设为 1; textbox 设为2
就可以了,类似这种label 的设为 N,textbox 设为 N+1即可label本身不能接收焦点,他会将焦点传给Tabindex序列的下一个控件
晕比我快2分钟肯定是在我登录和打字的时候