XorAndOr Active Member Licensed User Longtime User Apr 29, 2019 #1 Hi everyone, I have a project that uses multiple "parent" class modules, and every time I have to copy and paste the sub (public sub show) and (initialize (parent as form) or keep an empty .bas file and rename it. Do you know a way without copying and pasting the code? Thank you Code: Copy Sub Class_Globals Private fx As JFX End Sub Public Sub Show End Sub 'Initializes the object. You can add parameters to this method if needed. Public Sub Initialize(Parent As Form) End Sub
Hi everyone, I have a project that uses multiple "parent" class modules, and every time I have to copy and paste the sub (public sub show) and (initialize (parent as form) or keep an empty .bas file and rename it. Do you know a way without copying and pasting the code? Thank you Code: Copy Sub Class_Globals Private fx As JFX End Sub Public Sub Show End Sub 'Initializes the object. You can add parameters to this method if needed. Public Sub Initialize(Parent As Form) End Sub
Erel B4X founder Staff member Licensed User Longtime User Apr 29, 2019 #2 Sounds like a mistake. You should never duplicate code. Create a class with the common features and add an instance of it to each of the other classes (composition). Upvote 0
Sounds like a mistake. You should never duplicate code. Create a class with the common features and add an instance of it to each of the other classes (composition).
XorAndOr Active Member Licensed User Longtime User Apr 29, 2019 #3 Erel said: add an instance of it to each of the other classes (composition). Click to expand... I tried. You're right (as always) Thank you Upvote 0
Erel said: add an instance of it to each of the other classes (composition). Click to expand... I tried. You're right (as always) Thank you