hog Posted July 25, 2005 Posted July 25, 2005 I have some code in a command button which I would like to call from a sub, is this possible? If so what do I put in the arguments? Private Sub cmdNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdNext.Click Thnx Quote My website
techmanbd Posted July 25, 2005 Posted July 25, 2005 Just so I understand, you have code in the cmdNext, that you would also like to use from somewhere else? I would make another sub Private sub sharedsubwhatever(intVariable as int) ' only if you need to pass some variable though 'code end sub then call this sub in the cmdnext and from the other sub that needs to use the same code Private Sub cmdNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdNext.Click sharedsubwhatever(1) end sub private sub subthatneedssamecode sharedsubwhatever(1) end sub Quote Live as if you were to die tomorrow. Learn as if you were to live forever. Gandhi
hog Posted July 25, 2005 Author Posted July 25, 2005 Holy testicle Tuesday Batman! Why didn't I think of that :confused: Thnx :D :D Quote My website
SonicBoomAu Posted July 25, 2005 Posted July 25, 2005 hog, you can call your cmdNext_click eventusing the following cmdNext_click(sender,e) BUT this is considered lazy programming. The solution provided by techmanbd is the cleaner way of programming. Quote Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. -- Rick Cook, The Wizardry Compiled
hog Posted July 25, 2005 Author Posted July 25, 2005 Already implemented the cleaner way ;) Thnx chaps :D Quote My website
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.