Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Keypress repeat delay

Status
Not open for further replies.
Apr 27, 2006
126
GB
Hi (again),

Is there any way of avoiding the initial pause of the key repeat when holding down the key? (other than windows settings)

Basically, (and similarly to my prior mouse query) I am moving an image around a form.

The way I am currently doing this is

Code:
Private Sub UserForm_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
getkey = KeyAscii
movechar
End Sub
Code:
Public Sub movechar()
Select Case getkey
Case 56 'Up
frmmapscreen.imgchar.Top = frmmapscreen.imgchar.Top - 5
Case 50 'Down
frmmapscreen.imgchar.Top = frmmapscreen.imgchar.Top + 5
Case 52 'Left
Select Case Sheet2.Cells(2, 1)
Case "Barbarian"
    If frmmapscreen.imgchar.Picture <> frmholdimages.imgbabals.Picture Then
        frmmapscreen.imgchar.Picture = frmholdimages.imgbabals.Picture
    End If
Case "Dwarf"
    If frmmapscreen.imgchar.Picture <> frmholdimages.imgdwarfl.Picture Then
        frmmapscreen.imgchar.Picture = frmholdimages.imgdwarfl.Picture
    End If
Case "Sorcerer"
    If frmmapscreen.imgchar.Picture <> frmholdimages.imgsorcl.Picture Then
        frmmapscreen.imgchar.Picture = frmholdimages.imgsorcl.Picture
    End If
End Select
frmmapscreen.imgchar.Left = frmmapscreen.imgchar.Left - 5
Case 54 'Right
Select Case Sheet2.Cells(2, 1)
Case "Barbarian"
    If frmmapscreen.imgchar.Picture <> frmholdimages.imgbabars.Picture Then
        frmmapscreen.imgchar.Picture = frmholdimages.imgbabars.Picture
    End If
Case "Dwarf"
    If frmmapscreen.imgchar.Picture <> frmholdimages.imgdwarfr.Picture Then
        frmmapscreen.imgchar.Picture = frmholdimages.imgdwarfr.Picture
    End If
Case "Sorcerer"
    If frmmapscreen.imgchar.Picture <> frmholdimages.imgsorcr.Picture Then
        frmmapscreen.imgchar.Picture = frmholdimages.imgsorcr.Picture
    End If
End Select
frmmapscreen.imgchar.Left = frmmapscreen.imgchar.Left + 5
Case 13 'Return
Case 105 'I
Case 99 'C
Case 97 'A
End Select

End Sub


as you may have guessed, I am making a cheesy RPG in excel, mainly just to expand my programming skills (as i have only just started using VB and haven't bothered reading any guides.. only the help files.. can you tell? heheh)


So, when i hold down the left arrow, it moves one increment left, then pauses, then moves smoothly. Can this be avoided? I originally hoped it would run the code in "keypress" constantly while a key was depressed, but alas, it still suffers from the key repeat delay.

Thanks in advance :)

________
clueless
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top