Private Sub Text1_GotFocus(Index As Integer)
    Call SelText(Text1(Index))
    If Index >= 2 And Index <= 7 Then
        If Text1(Index).Locked = False Then
            mb(Index).ZOrder
            mb(Index).SetFocus
        Else
            mb(Index).Enabled = False
        End If
    End If
End Sub這是現在使用的代碼:
選擇完text1(15).text光標卻跑到第一控件上去了—text1(0),現在需要在選擇完畢text1(15).text后光標自動移動到下個控件上—text1(17).text上,並且按enter鍵的時候,光標也是選擇完text1(15)后光標移動到text1(17)上去。   在線等待!!!!!!!!!!

解决方案 »

  1.   

    補充一下,前面在填充text1(9)后光標也是直接回到第一個text1(0)。現在需要的是填充text1(9)后光標移動到text1(15)上,填充text1(15)后光標移動到text1(17)上去。
       text1(0),text1(9),text1(15)是通過cmdGet(0),cmdGet(9),cmdGet(15)填充的數據。       該如何處理! 
      

  2.   

    if index=9 then text1(15).setfocus
    if index=15 then text1(17).setfocus
      

  3.   

    if index=9 then text1(15).setfocus 
    if index=15 then text1(17).setfocus
    使用這是可以達到光標移動的效果,但是我現在在cmdGet(15)中查詢選取一個數據后,光標還是返回到第1個控件上。只能在點擊控件text1(15)后光標才會移動到text1(17)上。
        如何能達到這種效果?
        就是在cmdGet(15)中選取數據填充到text1(15)中后光標就移動到text1(17)上。
      

  4.   

    Private Sub Text1_LostFocus(Index As Integer)
        If Index = 0 Then
            If InStr(1, Text1(0), "S") <> 0 Then
                iType = 1
            Else
                iType = -1
            End If
        End If
        
        If Index = 9 Or Index = 12 Or Index = 15 Then
            If Trim(Text1(9)) = "054" Then
                iType = 2
            ElseIf iType <> 1 Then
                iType = 0
            End If
        End If
     
        If Text1(Index) <> "" Then
            Select Case Index
                Case 2, 3, 6, 7
                    If IsDate(Text1(Index)) Then
                        If Index Mod 2 = 0 Then
                            Text1(Index) = FormatDate(Text1(Index))
                        Else
                            Text1(Index) = FormatTime(Text1(Index))
                        End If
                    Else
                        Call MSGExcl("請輸入日期類型!", "Date")
                        Text1(Index) = ""
                        Text1(Index).SetFocus
                    End If
                Case 12, 17
                    If IsNumeric(Text1(Index)) Then
                        Text1(Index) = Format(Text1(Index), "##0.0000")
                    Else
                        Call MSGExcl("請輸入數值類型!", "Decimal")
                        Text1(Index) = ""
                        Text1(Index).SetFocus
                    End If
            End Select
        Else
            If Text1(Index) = "" And Text1(Index).Locked = False Then
                Select Case Index
                    Case 0
                        Text1(1) = ""
                        Text1(13) = ""
                    Case 9
                        Text1(8) = ""
                        Text1(10) = ""
                        Text1(11) = ""
                    Case 15
                        Text1(16) = ""
                End Select
            End If
        End If
        Call RestoreBackColor(Text1(Index))
    End Sub
      

  5.   

    Private Sub Text1_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
    If Index = 9 And KeyCode = vbKeyReturn Then Text1(15).SetFocus
    If Index = 15 And KeyCode = vbKeyReturn Then Text1(17).SetFocus
    End Sub
      

  6.   

    Private Sub Text1_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
        '當按F12時
        If KeyCode = 123 Then
            Select Case Index
            Case 0
                If Text1(1).Text = "" And KeyCode = 13 Then  'Len(Trim(Text1(Index).Text)) < 5 And當然機台名稱為空,或機台編碼不滿6位,打開搜索窗口
                    Call GetDataPF(1, 0)
                Else
                    Call GetDataPF(0, Index, KeyCode)
                End If
            Case 9
                If Text1(Index - 1).Text = "" And KeyCode = 13 Then
                    Call GetDataPF(1, Index)
                Else
                    Call GetDataPF(0, Index, KeyCode)
                End If
            Case 15
                Call GetDataPA
            Case Else
                '
            End Select
        Else
            If Index = 0 Then
                If Text1(1).Text = "" And KeyCode = 13 Then  'Len(Trim(Text1(Index).Text)) < 5 And當然機台名稱為空,或機台編碼不滿6位,打開搜索窗口
                    Call GetDataPF(1, 0)
                Else
                    Call GetDataPF(0, Index, KeyCode)
                End If
            ElseIf Index = 9 Then
                If Text1(Index - 1).Text = "" And KeyCode = 13 Then
                    Call GetDataPF(1, Index)
                Else
                    Call GetDataPF(0, Index, KeyCode)
                End If
            ElseIf Index = 15 Then
                If KeyCode = 13 Then
                    Call GetDataPA
                End If
            Else
                Call KeyPressTXT(Text1(Index), KeyCode)
            End If
        End IfEnd Sub這是現在的代碼:加進去你的代碼沒有反應