在Textbox拥有焦点时,怎样在按下Tab键的时候不转移焦点,而是在文本框中插入一个制表符呢?

解决方案 »

  1.   

    吼吼
    不太会这样的
    学习学习
    如果一个窗体里只有一个text的话想得到你的要求如下
    code:
    Private Sub Text1_KeyPress(KeyAscii As Integer)
        If KeyAscii = 9 Then
            Text1.Text = Text1.Text & vbTab
        End If
    End Sub
      

  2.   

    在text1中按TAB鍵時,好像不能觸發Text1_KeyPress事件
    在Text1_LostFocus事件中試試
      

  3.   

    用key_press 事件和Key_UP事件!
      

  4.   

    Private Sub Text1_GotFocus()
        Dim obj As Control
        
        For Each obj In Me.Controls
            obj.TabStop = False
        Next
        
    End SubPrivate Sub Text1_KeyPress(KeyAscii As Integer)
        If KeyAscii = Asc(vbTab) Then
            Text1.SelText = vbTab
        End If
    End SubPrivate Sub Text1_LostFocus()
        Dim obj As Control
        
        For Each obj In Me.Controls
            obj.TabStop = True
        Next
        
    End Sub
      

  5.   

    If KeyAscii = 9 Then
            Text1.Text = Text1.Text & vbTab
        End If