PROKA Posted May 6, 2004 Posted May 6, 2004 I have a 'form1' form (a class) with a Button1_click Sub on it How do I make this sub NotInheritable ? ( I have another form (form2) , Inheriting form1 and I want to put in another code for Button1_click ) Quote Development & Research Department @ Elven Soft
Administrators PlausiblyDamp Posted May 6, 2004 Administrators Posted May 6, 2004 You can only mark classes as NotInheritable, not individual functions. If you want to prevent a sub being overriden you can mark it NotOverridable. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
PROKA Posted May 7, 2004 Author Posted May 7, 2004 in The 2nd form, I want to write another code for Button1_sub for example, if in form 1, Button1_sub does Msgbox("Form1,Button1") and I inherit form 1 ( in form 2 ) it will do the same well , I want the button in form 2 to do msgbox("Form2,button1") Quote Development & Research Department @ Elven Soft
JABE Posted May 10, 2004 Posted May 10, 2004 Apply Overridable on the parent sub while applying Overrides on the child sub. Quote
PROKA Posted May 11, 2004 Author Posted May 11, 2004 ok, it works now, except that the sub that overrides runs twice . Quote Development & Research Department @ Elven Soft
Administrators PlausiblyDamp Posted May 11, 2004 Administrators Posted May 11, 2004 Are you calling it twice? Seems an unusual side effect. Any chance you could post the relevant code (base class , sub class and calling code for example)? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
PROKA Posted May 12, 2004 Author Posted May 12, 2004 (edited) Sure, Check the attachment Edited March 13, 2007 by PROKA Quote Development & Research Department @ Elven Soft
Administrators PlausiblyDamp Posted May 13, 2004 Administrators Posted May 13, 2004 In form2 you don't need the Handles Button1.Click on the following line Protected Overrides Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click The event is already being handled by the base class' Handles statement. Remove the handles clause and things sould now work. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
PROKA Posted May 14, 2004 Author Posted May 14, 2004 Good point :) Thanks ! Quote Development & Research Department @ Elven Soft
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.