Cycling through a text box array.

02-11-2005, 09:56 AM
Ive created an array of several textboxes and i want to go fome one to other with the key up and down,i tried with the vbKeyUp and vbKeyDown and cannot get the textbox recognise that im pressing the directional key for cycling, not moving through the text it is insed the box.

Some code tips?

Thank you!

02-11-2005, 10:15 AM
Are you using the Form_Keydown and Form_Keyup events?

if so you may need to set your Form's Keypreview property to True.

02-11-2005, 11:07 AM
Nay, i dont use that stuff. How you say i have to do?

02-11-2005, 02:47 PM
Nevermind that.

You said you have an array of textboxes, like in a control array?

I tried this on a control array of textboxes and it seemed to work fine with the arrow keys

Private Sub Text1_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)

On Error Resume Next

If KeyCode = vbKeyDown Then
Text1(Index + 1).SetFocus
ElseIf KeyCode = vbKeyUp Then
Text1(Index - 1).SetFocus
End If

End Sub

Hope that what you meant :)

02-11-2005, 08:37 PM
Thanks man. I figured it out, i had to use KeyDown instead of KeyPress. Dont know why, but tested and worked. Now that i see your code, i realized i was correct.

Again, thanks.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum