From: "Dimmer" Newsgroups: comp.lang.basic.visual.misc Subject: Newbie question about nested subroutines Date: Fri, 7 Oct 2011 05:48:15 +1100 Lines: 35 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6109 NNTP-Posting-Host: 203.219.176.51 X-Original-NNTP-Posting-Host: 203.219.176.51 Message-ID: <4e8df7f8$1@dnews.tpgi.com.au> X-Trace: dnews.tpgi.com.au!tpg.com.au 1317926904 203.219.176.51 (7 Oct 2011 05:48:24 +1000) Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!feed.news.qwest.net!mpls-nntp-06.inet.qwest.net!nntp1.phx1.gblx.net!nntp.gblx.net!nntp.gblx.net!nntp3.phx1!dnews.tpgi.com.au!tpg.com.au!not-for-mail Xref: x330-a1.tempe.blueboxinc.net comp.lang.basic.visual.misc:440 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.