注册 登录
编程论坛 VB6论坛

焦点跳转

snrtjat 发布于 2013-08-22 17:15, 344 次点击
我有60个textbox控件数组,焦点是从text1(0)到text1(59);
程序代码:
private sub text1_keypress(index as integer,keyascii as integer)
if keyascii=13 then
   text1(index+1).setfocus
   if index=59 then text1(0).setfocus
end if
end sub
现在的问题是:当我的光标第二次定位到text1(0)时,输入信息时第一个字符要按两次才能输入进去.
为什么? 谁能帮我解决一下?
其它的textbox没有这个问题{text1(1)到text1(59)}
2 回复
#2
风吹过b2013-08-22 18:33
程序代码:
Private Sub text1_keypress(index As Integer, keyascii As Integer)
'On Error Resume Next
If keyascii = 13 Then
    If index = 59 Then
        Text1(0).SetFocus
    Else
        Text1(index + 1).SetFocus
    End If
End If
End Sub



没发现你说的情况啊。
-------
你的代码有点小问题。会报 元素 60 不存在。


---------
载入 1-59 个文本框的代码。
程序代码:
Dim i As Long
For i = 1 To 59
    Load Text1(i)
    With Text1(i)
        .Left = Text1(i - 1).Left + .Width
        If .Left + .Width + 120 > Me.ScaleWidth Then
            .Top = Text1(i - 1).Top + .Height
            .Left = 120
        Else
            .Top = Text1(i - 1).Top
        End If
        .Visible = True
    End With
Next i
#3
snrtjat2013-08-23 11:22
谢谢风老师,我的code里有使用快捷键来调用运行的,刚刚才到找问题,就是在调用的时候出现了焦点输入问题,现在已经解决了,非常感谢您的解答!
1