|
-
May 19th, 2003, 05:33 PM
#1
Thread Starter
Addicted Member
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:
Public Sub NavigateThruCells(KeyAscii As Integer, mfgDeps As MSFlexGrid)
Dim strContents As String
With mfgDeps
'Get the text contents of the cell with focus
strContents = .TextMatrix(.RowSel, .ColSel)
'Check if the backspace key was pressed
If KeyAscii = 8 Then
'Don't do anything if the backspace key was pressed
'and the cell with focus is empty
If Trim(strContents) = "" Then Exit Sub
'Delete the last character
strContents = Mid(strContents, 1, Len(strContents) - 1)
.TextMatrix(.RowSel, .ColSel) = strContents
'Check if the enter key was pressed
ElseIf KeyAscii = 13 Then
'Check if the cell with focus is on the last collumn
'If not then focus on the next collumn
If .Col < .Cols - 1 Then
.Col = .ColSel + 1
'If it is the last collumn then go back to the
'first collumn but adjust to the next row
Else
.Col = 1
'Check if the cell with focus belongs to the
'last row. If not then go to the next row
If .Row < .Rows - 1 Then
.Row = .RowSel + 1
'If it is the last row then check for an empty cell
Else
If CheckIfFull(mfgDeps) = False Then
.Row = 1
.Col = 1
'If all cells are not empty then add a
'new row and focus on that row
Else
.Rows = .Rows + 1
.Col = 1
.Row = .RowSel + 1
End If
End If
End If
'If the neither the backspace nor the enter
'key was pressed, then concatenate the pressed key
'with the string in the cell
Else
'Do nothing if the escape key was pressed
If KeyAscii = 27 Then Exit Sub
.TextMatrix(.RowSel, .ColSel) = _
.TextMatrix(.RowSel, .ColSel) & Chr(KeyAscii)
End If
End With
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+++
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|