我要做一个文本框通过回车键聚集并选择其中字符的功能,如果输入错误或通过别的什么事件触发聚集也可以选择其中的字符,可是实现不了:
Private Sub text1_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then
    Text2.SetFocus
    Text2.SelLength = Len(Text2.Text)
    End If
End Sub
请大家指点!

解决方案 »

  1.   

    form.keypreview=true
    然后在form_keydown中处理
      

  2.   

    If KeyAscii = 13 Then
        Text2.SetFocus
        Text2.Selstart = 0  '加这句,开始位置是0还是1,我不是很清楚了,你试试吧。
        Text2.SelLength = Len(Text2.Text)
    End If
      

  3.   

    谢谢WallesCai(加班费超过工资,唉,是快乐还是不幸呢)! 
    好用了:)
    可是我的另一个工程中的窗体就是像我上面那样写的就好用啊。
    这里怎么就不好用了呢?
    怎么非要加上text2.selstart=0这句话了呢?