Results 1 to 2 of 2

Thread: Keyascii question

  1. #1

    Thread Starter
    Addicted Member ripple214's Avatar
    Join Date
    Nov 2002
    Location
    In Front of My Computer
    Posts
    141

    Keyascii question

    how do you make a flexgrid move through each cell by pressing the tab key. I can do it with the enter key but i couldn't make it work with the tab key. Here's my code;
    VB Code:
    1. Public Sub NavigateThruCells(KeyAscii As Integer, mfgDeps As MSFlexGrid)
    2.     Dim strContents As String
    3.     With mfgDeps
    4.         'Get the text contents of the cell with focus
    5.         strContents = .TextMatrix(.RowSel, .ColSel)
    6.         'Check if the backspace key was pressed
    7.         If KeyAscii = 8 Then
    8.             'Don't do anything if the backspace key was pressed
    9.             'and the cell with focus is empty
    10.             If Trim(strContents) = "" Then Exit Sub
    11.             'Delete the last character
    12.             strContents = Mid(strContents, 1, Len(strContents) - 1)
    13.             .TextMatrix(.RowSel, .ColSel) = strContents
    14.         'Check if the enter key was pressed
    15.         ElseIf KeyAscii = 13 Then
    16.             'Check if the cell with focus is on the last collumn
    17.             'If not then focus on the next collumn
    18.             If .Col < .Cols - 1 Then
    19.                 .Col = .ColSel + 1
    20.             'If it is the last collumn then go back to the
    21.             'first collumn but adjust to the next row
    22.             Else
    23.                 .Col = 1
    24.                 'Check if the cell with focus belongs to the
    25.                 'last row. If not then go to the next row
    26.                 If .Row < .Rows - 1 Then
    27.                     .Row = .RowSel + 1
    28.                 'If it is the last row then check for an empty cell
    29.                 Else
    30.                     If CheckIfFull(mfgDeps) = False Then
    31.                         .Row = 1
    32.                         .Col = 1
    33.                      'If all cells are not empty then add a
    34.                     'new row and focus on that row
    35.                     Else
    36.                         .Rows = .Rows + 1
    37.                         .Col = 1
    38.                         .Row = .RowSel + 1
    39.                     End If
    40.                 End If
    41.             End If
    42.         'If the neither the backspace nor the enter
    43.         'key was pressed, then concatenate the pressed key
    44.         'with the string in the cell
    45.         Else
    46.             'Do nothing if the escape key was pressed
    47.             If KeyAscii = 27 Then Exit Sub
    48.             .TextMatrix(.RowSel, .ColSel) = _
    49.             .TextMatrix(.RowSel, .ColSel) & Chr(KeyAscii)
    50.         End If
    51.     End With
    52. End Sub
    Also, what's the ascii value of the delete key?
    Last edited by ripple214; May 19th, 2003 at 05:47 PM.
    [vbcode]
    If SymptomsPersist Then Goto VBForum
    [/vbcode]
    This is our world now...the world of the electron and the switch, the beauty of the baud.We make use of a service already existing without paying for what could be dirt cheep if it wasn't run by profiteering gluttons, and you call us criminals. We explore...and you call us criminals. We exist without skin color, without nationality, without religious bias...and you call us criminals. You build atomic bombs, wage wars, murder, cheat, and lie to us and try to make us believe it is for our own good, yet we're the criminals. Yes, I am a criminal. My crime is that of curiosity. My crime is that of judging people by what they say and think, not what they look like. My crime is that of outsmarting you, something that you will never forgive me for. I am a hacker and this is my manifesto.You may stop this individual, but you can't stop us all...after all, we're all alike."

    +++The Mentor+++

  2. #2
    Fanatic Member doofusboy's Avatar
    Join Date
    Apr 2003
    Posts
    526
    KeyCode for Delete key is 46

    KeyCode for Tab key is 9
    Do canibals not eat clowns because they taste funny?

Posting Permissions

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



Click Here to Expand Forum to Full Width