我窗体上有以下text控件数组排列text(1) text(4) text(7) text(10)  
text(2) text(5) text(8) text(11) 
text(3) text(6) text(9) text(12)我想按下左箭头光标就跳到左面的text控件上
按下右箭头光标就跳到右面的text控件上  应该怎么做啊?

解决方案 »

  1.   

    Private Sub Text1_KeyUp(Index As Integer, KeyCode As Integer, Shift As Integer)
        If KeyCode = 37 Then
            Text1(Index - 1).SetFocus
        ElseIf KeyCode = 39 Then
            Text1(Index + 1).SetFocus
        End If
    End Sub
      

  2.   

    Private Sub Text2_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
    If KeyCode = 13 Then'13是回车
      Text2(Index + 1).SetFocus
      
     End
    End Sub
      

  3.   

    VBkeyUp,vbkeydown,vbkeyright etc.
      

  4.   

    最好不要用左箭头和右箭头
    用上下箭头(39,37分别该为38,40)
    Private Sub Text1_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
    If KeyCode = 39 Then
      If Index < Text1.Count - 1 Then
        Text1(Index + 1).SetFocus
      Else
        Text1(Text1.LBound).SetFocus
      End If
    ElseIf KeyCode = 37 Then
      If Index > Text1.LBound Then
        Text1(Index - 1).SetFocus
      Else
        Text1(Text1.Count - 1).SetFocus
      End If
      
    End If
    End Sub