Dimmer
2011-10-06 18:48:15 UTC
Hi all
I am trying to arrange to access this sub a number of times in a program.
The sub works fine in intercepting ESC and certain other keystrokes.
I want to somehow arrange to repeatedly use it and this instictively
suggests that it should be in a subroutine. But it is already in one! Is
there such a thing as nested subroutines? I want to call it and pass to it
the particular Textboxes and Label concerned. I emphasise that it works
fine but I just don't want to have to have it appearing 13 times in a 13
field form I have designed.
Any ideas?
Private Sub Text8_KeyPress(KeyAscii As Integer)
Label23.Caption = "" '*** this label is used elsewhere for warning
messages against that (8 in this case) text field
If KeyAscii = 27 Then '*** ESC to blank and step back
Text8.Text = ""
Text7.SetFocus
ElseIf KeyAscii <> 8 Then '***overtype
Text8.SelLength = 1
End If
Call AlibModule.EnterTabKey(KeyAscii) 'this is a standard routine (Alib
is Alan library!) I have developed that treats ENTER and TAB the same. It
works fine
End Sub
The above all works fine. It's just that I want to avoid typing it all out
again and again with different values for the LabelNo, TextNo, and
PriorTextNo.
I am trying to arrange to access this sub a number of times in a program.
The sub works fine in intercepting ESC and certain other keystrokes.
I want to somehow arrange to repeatedly use it and this instictively
suggests that it should be in a subroutine. But it is already in one! Is
there such a thing as nested subroutines? I want to call it and pass to it
the particular Textboxes and Label concerned. I emphasise that it works
fine but I just don't want to have to have it appearing 13 times in a 13
field form I have designed.
Any ideas?
Private Sub Text8_KeyPress(KeyAscii As Integer)
Label23.Caption = "" '*** this label is used elsewhere for warning
messages against that (8 in this case) text field
If KeyAscii = 27 Then '*** ESC to blank and step back
Text8.Text = ""
Text7.SetFocus
ElseIf KeyAscii <> 8 Then '***overtype
Text8.SelLength = 1
End If
Call AlibModule.EnterTabKey(KeyAscii) 'this is a standard routine (Alib
is Alan library!) I have developed that treats ENTER and TAB the same. It
works fine
End Sub
The above all works fine. It's just that I want to avoid typing it all out
again and again with different values for the LabelNo, TextNo, and
PriorTextNo.