VBGood网站全文搜索 Google

首页 - 经验之谈 - 在GotFocus时快速选择文本
发表评论(0)作者:不详, 平台:VB6.0+Win98, 阅读:9309, 日期:2000-10-30
Quick Text Select On GotFocus

When working with data entry controls, the current value in the control often needs to be selected when the control received focus. This allows the user to immediately begin typing over any previous value. Here注释:s a quick subroutine to do just that:

Public Sub FocusMe(ctlName As Control)
    With ctlName
        .SelStart = 0
        .SelLength = Len(ctlName)
    End With
End Sub

Now add a call to this subroutine in the GotFocus event of the input controls:

Private Sub txtFocusMe_GotFocus()
    Call FocusMe(txtFocusMe)
End Sub