Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    Oct 2003
    Location
    Guelph, Ontario, Canada
    Posts
    428
    Thanks
    0
    Thanked 0 Times in 0 Posts

    KeyCodes not working (2000 all updates)

    Here is code behind a calendar form. This is not the Microsoft ActiveX calendar control.

    <code>Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    ' Allow for paging up and down through months
    Select Case KeyCode
    Case 33 ' Page up
    Call labMthSub_Click
    Case 34 ' Page down
    Call labMthAdd_Click
    Case 93 ' right square bracket
    Call labYrAdd_Click
    Case 94 ' left square bracket
    Call labYrSub_Click
    End Select
    End Sub</code>

    Is there any reason the last two cases do not work - the 93 and 94 key codes?

    I should add that no matter what keys I plug into those 2 lines, they don't work. However the first 2 lines work fine.

    Here are the additional code lines called by the 4 lines
    <code>
    Private Sub labMthAdd_Click()
    labDat.Caption = Format(CDate(Format(labDat.Caption, "dd-mmm-yyyy")) + 31, "mmmm yyyy") ' Re-banner the form with next month
    fctnPopulate ' Function to set and format the calendar grid
    End Sub

    Private Sub labMthSub_Click()
    labDat.Caption = Format(CDate(Format(labDat.Caption, "dd-mmm-yyyy")) - 1, "mmmm yyyy") ' Re-banner the form with previous month
    fctnPopulate ' Function to set and format the calendar grid
    End Sub

    Private Sub labYrAdd_Click()
    labDat.Caption = Format(CDate(Format(labDat.Caption, "dd-mmm-yyyy")) + 366, "mmmm yyyy") ' Re-banner the form with this month next year
    fctnPopulate ' Function to set and format the calendar grid
    End Sub

    Private Sub labYrSub_Click()
    labDat.Caption = Format(CDate(Format(labDat.Caption, "dd-mmm-yyyy")) - 365, "mmmm yyyy") ' Re-banner the form with this month last year
    fctnPopulate ' Function to set and format the calendar grid
    End Sub</code>

    Thanks.

    Tom

  2. #2
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: KeyCodes not working (2000 all updates)

    I think your problem is that the keycode for "[" is 219, and for "]" it is 221. The values you were using are the ASCII values used in the KeyPress event, not the KeyDown event.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  3. #3
    4 Star Lounger
    Join Date
    Oct 2003
    Location
    Guelph, Ontario, Canada
    Posts
    428
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: KeyCodes not working (2000 all updates)

    Thanks, Mark

    Never tumbled to the fact they would be different.

    Works like a charm.

    Tom

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •