# Re: textbox 往上一格或下一格的问题~~~非常紧急啊

Posted by dino on August 14, 1999 at 14:51:40:

In Reply to: textbox 往上一格或下一格的问题~~~非常紧急啊 posted by 想得快急死了的人 on August 14, 1999 at 14:07:49:

有一个例子,但你要加以修改
在form里,有text1(0),text1(1)...text1(4)

Private Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer)
If KeyAscii = 13 Then 'enter的ascii
If Index - 1 >= 0 Then
Text1(Index - 1).SetFocus
Else
Text1(4).SetFocus
End If
End If
If KeyAscii = 45 Then '-的ascii
KeyAscii = 0
If Index + 1 <= 4 Then
Text1(Index + 1).SetFocus
Else
Text1(0).SetFocus
End If
End If

按enter会往前跳,按-会往后跳

Follow Ups: