Сţµç×ÓÊé > ÆäËûµç×ÓÊé > VB2008´ÓÈëÃŵ½¾«Í¨(PDF¸ñʽӢÎÄ°æ) >

µÚ70ÕÂ

VB2008´ÓÈëÃŵ½¾«Í¨(PDF¸ñʽӢÎÄ°æ)-µÚ70ÕÂ

С˵£º VB2008´ÓÈëÃŵ½¾«Í¨(PDF¸ñʽӢÎÄ°æ) ×ÖÊý£º ÿҳ3500×Ö

°´¼üÅÌÉÏ·½Ïò¼ü ¡û »ò ¡ú ¿É¿ìËÙÉÏÏ·­Ò³£¬°´¼üÅÌÉ쵀 Enter ¼ü¿É»Øµ½±¾ÊéĿ¼ҳ£¬°´¼üÅÌÉÏ·½Ïò¼ü ¡ü ¿É»Øµ½±¾Ò³¶¥²¿£¡
¡ª¡ª¡ª¡ªÎ´ÔĶÁÍꣿ¼ÓÈëÊéÇ©ÒѱãÏ´μÌÐøÔĶÁ£¡






¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Class¡¡Derived¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Inherits¡¡Base¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Public¡¡Overloads¡¡Sub¡¡Method£¨£©¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Console¡£WriteLine£¨¡¨Derived¡£Method¡¨£©¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡Sub¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡Class¡¡


¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­Page¡¡211¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡CH¡¡AP¡¡T¡¡E¡¡R¡¡¡¡¡¡7¡¡¡¡¡¡¡ö¡¡¡¡¡¡¡¡L¡¡E¡¡AR¡¡N¡¡IN¡¡G¡¡¡¡¡¡AB¡¡O¡¡U¡¡T¡¡¡¡¡¡CO¡¡M¡¡P¡¡O¡¡N¡¡E¡¡N¡¡TS¡¡¡¡¡¡AN¡¡D¡¡¡¡¡¡C¡¡L¡¡AS¡¡S¡¡¡¡H¡¡I¡¡E¡¡R¡¡AR¡¡C¡¡HI¡¡E¡¡S¡¡189¡¡



¡¡¡¡¡¡¡¡Module¡¡Test¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Public¡¡Sub¡¡Run£¨£©¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Dim¡¡derivedCls¡¡As¡¡Derived¡¡=¡¡New¡¡Derived£¨£©¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Dim¡¡baseCls¡¡As¡¡Base¡¡=¡¡derivedCls¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡'¡¡Calls¡¡Derived¡£Method¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡derivedCls¡£Method£¨£©¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡'¡¡Calls¡¡Base¡£Method¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡baseCls¡£Method£¨£©¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡Sub¡¡

¡¡¡¡¡¡¡¡End¡¡Module¡¡



¡¡¡¡¡¡¡¡o¡¡¡¡Keywords¡¡used£º¡¡Overloads¡¡in¡¡the¡¡derived¡¡class¡¡to¡¡indicate¡¡the¡¡method¡¡is¡¡being¡¡overloaded¡£¡¡



¡¡¡¡¡¡¡¡o¡¡¡¡Overloading¡¡a¡¡method¡¡means¡¡to¡¡change¡¡the¡¡functionality¡¡of¡¡the¡¡method¡¡in¡¡the¡¡derived¡¡class¡£¡¡



¡¡¡¡¡¡¡¡o¡¡¡¡Which¡¡method¡¡is¡¡called¡¡in¡¡the¡¡inheritance¡¡depends¡¡on¡¡the¡¡type¡¡of¡¡the¡¡variable¡¡on¡¡which¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡the¡¡method¡¡is¡¡called¡£¡¡Thus£»¡¡if¡¡the¡¡variable¡¡is¡¡of¡¡type¡¡Base£»¡¡Base¡£Method£¨£©¡¡is¡¡called£»¡¡if¡¡the¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡variable¡¡is¡¡of¡¡type¡¡Derived£»¡¡Derived¡£Method£¨£©¡¡is¡¡called¡£¡¡



Scenario¡¡2£º¡¡Overriding¡¡Base¡¡Class¡¡Functionality¡¡



¡¡¡¡¡¡¡¡Class¡¡Base¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Public¡¡Overridable¡¡Sub¡¡Method£¨£©¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Console¡£WriteLine£¨¡¨Base¡£Method¡¨£©¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡Sub¡¡

¡¡¡¡¡¡¡¡End¡¡Class¡¡



¡¡¡¡¡¡¡¡Class¡¡Derived¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Inherits¡¡Base¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Public¡¡Overrides¡¡Sub¡¡Method£¨£©¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Console¡£WriteLine£¨¡¨Derived¡£Method¡¨£©¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡Sub¡¡

¡¡¡¡¡¡¡¡End¡¡Class¡¡



¡¡¡¡¡¡¡¡Module¡¡Test¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Public¡¡Sub¡¡Run£¨£©¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Dim¡¡derivedCls¡¡As¡¡Derived¡¡=¡¡New¡¡Derived£¨£©¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Dim¡¡baseCls¡¡As¡¡Base¡¡=¡¡derivedCls¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡'¡¡Calls¡¡Derived¡£Method¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡derivedCls¡£Method£¨£©¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡'¡¡Calls¡¡Derived¡£Method¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡baseCls¡£Method£¨£©¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡Sub¡¡

¡¡¡¡¡¡¡¡End¡¡Module¡¡


¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­Page¡¡212¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­

190¡¡¡¡¡¡¡¡¡¡¡¡¡¡CH¡¡AP¡¡T¡¡E¡¡R¡¡¡¡¡¡7¡¡¡¡¡¡¡ö¡¡¡¡¡¡¡¡L¡¡E¡¡A¡¡R¡¡N¡¡IN¡¡G¡¡¡¡¡¡AB¡¡OU¡¡T¡¡¡¡¡¡CO¡¡M¡¡P¡¡O¡¡N¡¡E¡¡N¡¡TS¡¡¡¡¡¡AN¡¡D¡¡¡¡C¡¡L¡¡AS¡¡S¡¡¡¡H¡¡I¡¡E¡¡R¡¡AR¡¡C¡¡H¡¡IE¡¡S¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡o¡¡Keywords¡¡used£º¡¡Overridable¡¡in¡¡the¡¡base¡¡class¡¡to¡¡indicate¡¡the¡¡method¡¡behavior¡¡can¡¡be¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡changed¡¡in¡¡the¡¡derived¡¡class¡£¡¡Overrides¡¡is¡¡used¡¡in¡¡the¡¡derived¡¡classes¡¡to¡¡indicate¡¡a¡¡method¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡with¡¡the¡¡new¡¡behavior¡£¡¡Multiple¡¡levels¡¡of¡¡inheritance¡¡require¡¡multiple¡¡usages¡¡of¡¡Overrides¡£¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡o¡¡Overriding¡¡a¡¡method¡¡means¡¡to¡¡change¡¡the¡¡behavior¡¡of¡¡the¡¡method¡¡in¡¡the¡¡base¡¡class¡¡to¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡that¡¡of¡¡the¡¡derived¡¡class¡£¡¡If¡¡there¡¡are¡¡multiple¡¡levels¡¡of¡¡inheritance£»¡¡then¡¡the¡¡functionality¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡used¡¡is¡¡the¡¡instantiated¡¡type¡£¡¡¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡o¡¡You¡¡can¡¡also¡¡define¡¡a¡¡Overridable¡¡base¡¡class¡¡method¡¡using¡¡the¡¡MustOverride¡¡keyword¡£¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡The¡¡difference¡¡between¡¡Overridable¡¡and¡¡MustOverride¡¡is¡¡that¡¡Overridable¡¡has¡¡a¡¡method¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡or¡¡property¡¡implementation¡¡in¡¡the¡¡base¡¡class£»¡¡whereas¡¡MustOverride¡¡has¡¡no¡¡implemen

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡tation¡¡in¡¡the¡¡base¡¡class¡£¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Scenario¡¡3£º¡¡Implementing¡¡an¡¡Interface¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Interface¡¡IInterface¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Sub¡¡Method£¨£©¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡Interface¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Class¡¡Implementation¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Implements¡¡IInterface¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Public¡¡Sub¡¡Method£¨£©¡¡Implements¡¡IInterface¡£Method¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Console¡£WriteLine£¨¡¨Implementation¡£Method¡¨£©¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡Sub¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡Class¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Module¡¡Test¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Public¡¡Sub¡¡Run£¨£©¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Dim¡¡implementation¡¡As¡¡Implementation¡¡=¡¡New¡¡Implementation£¨£©¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Dim¡¡inst¡¡As¡¡IInterface¡¡=¡¡implementation¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡'¡¡Calls¡¡Implementation¡£Method¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡implementation¡£Method£¨£©¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡'¡¡Calls¡¡Implementation¡£Method¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡inst¡£Method£¨£©¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡Sub¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡Module¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡o¡¡Keywords¡¡used£º¡¡none¡£¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡o¡¡The¡¡class¡¡that¡¡implements¡¡the¡¡interface¡¡has¡¡a¡¡behavior£»¡¡like¡¡when¡¡a¡¡class¡¡subclasses¡¡and¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡implements¡¡a¡¡MustOverride¡¡method¡£¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡o¡¡Whether¡¡the¡¡variable¡¡is¡¡an¡¡interface¡¡type¡¡or¡¡an¡¡implementation¡¡type£»¡¡the¡¡method¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Implementation¡£Method£¨£©¡¡is¡¡called¡£¡¡


¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­Page¡¡213¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡CH¡¡AP¡¡T¡¡E¡¡R¡¡¡¡¡¡7¡¡¡¡¡¡¡ö¡¡¡¡¡¡¡¡L¡¡E¡¡AR¡¡N¡¡IN¡¡G¡¡¡¡¡¡AB¡¡O¡¡U¡¡T¡¡¡¡¡¡CO¡¡M¡¡P¡¡O¡¡N¡¡E¡¡N¡¡TS¡¡¡¡¡¡AN¡¡D¡¡¡¡¡¡C¡¡L¡¡AS¡¡S¡¡¡¡H¡¡I¡¡E¡¡R¡¡AR¡¡C¡¡HI¡¡E¡¡S¡¡191¡¡



Scenario¡¡4£º¡¡Implementing¡¡Two¡¡Interfaces¡¡with¡¡Same¡¡Method/Property¡¡Name¡¡



¡¡¡¡¡¡Interface¡¡IInterface1¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Sub¡¡Method£¨£©¡¡

¡¡¡¡¡¡¡¡End¡¡Interface¡¡



¡¡¡¡¡¡¡¡Interface¡¡IInterface2¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Sub¡¡Method£¨£©¡¡

¡¡¡¡¡¡¡¡End¡¡Interface¡¡



¡¡¡¡¡¡¡¡Class¡¡Implementation¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Implements¡¡IInterface1£»¡¡IInterface2¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Public¡¡Sub¡¡Method1£¨£©¡¡Implements¡¡IInterface1¡£Method¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Console¡£WriteLine£¨¡¨Implementation¡£IInterface1¡£Method¡¨£©¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡Sub¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Private¡¡Sub¡¡Method2£¨£©¡¡Implements¡¡IInterface2¡£Method¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Console¡£WriteLine£¨¡¨Implementation¡£IInterface2¡£Method¡¨£©¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡Sub¡¡

¡¡¡¡¡¡¡¡End¡¡Class¡¡



¡¡¡¡¡¡¡¡Module¡¡Test¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Public¡¡Sub¡¡Run£¨£©¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Dim¡¡implementation¡¡As¡¡Implementation¡¡=¡¡New¡¡Implementation£¨£©¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Dim¡¡inst1¡¡As¡¡IInterface1¡¡=¡¡implementation¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Dim¡¡inst2¡¡¡¡As¡¡IInterface2¡¡=¡¡implementation¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡'¡¡Calls¡¡Implementation¡£Method1¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡inst1¡£Method£¨£©¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡'¡¡Calls¡¡Implementation¡£Method2¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡inst2¡£Method£¨£©¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡Sub¡¡

¡¡¡¡¡¡¡¡End¡¡Module¡¡



¡¡¡¡¡¡¡¡o¡¡¡¡Keywords¡¡used£º¡¡special¡¡notation¡¡for¡¡the¡¡implementation¡¡of¡¡a¡¡particular¡¡interface¡¡method¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡£¨for¡¡example£»¡¡Implements¡¡IInterface1¡£Method¡¡and¡¡Implements¡¡IInterface2¡£Method£©¡£¡¡



¡¡¡¡¡¡¡¡o¡¡¡¡The¡¡methods¡¡that¡¡are¡¡converted¡¡to¡¡implement¡¡a¡¡particular¡¡interface¡¡can¡¡still¡¡be¡¡called¡£¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡In¡¡the¡¡example£»¡¡Method1£¨£©¡¡is¡¡declared¡¡as¡¡Public£»¡¡and¡¡thus¡¡if¡¡you¡¡have¡¡a¡¡reference¡¡to¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡Implementation£»¡¡then¡¡you¡¡can¡¡call¡¡Method1£¨£©¡£¡¡



Scenario¡¡5£º¡¡Implementing¡¡an¡¡Interface¡¡That¡¡Allows¡¡Overriding¡¡



¡¡¡¡¡¡¡¡Interface¡¡IInterface¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Sub¡¡Method£¨£©¡¡

¡¡¡¡¡¡¡¡End¡¡Interface¡¡


¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­Page¡¡214¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­

192¡¡¡¡¡¡¡¡¡¡¡¡CH¡¡AP¡¡T¡¡E¡¡R¡¡¡¡¡¡7¡¡¡¡¡¡¡ö¡¡¡¡¡¡¡¡L¡¡E¡¡A¡¡R¡¡N¡¡IN¡¡G¡¡¡¡¡¡AB¡¡OU¡¡T¡¡¡¡¡¡CO¡¡M¡¡P¡¡O¡¡N¡¡E¡¡N¡¡TS¡¡¡¡¡¡AN¡¡D¡¡¡¡C¡¡L¡¡AS¡¡S¡¡¡¡H¡¡I¡¡E¡¡R¡¡AR¡¡C¡¡H¡¡IE¡¡S¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Class¡¡Implementation¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Implements¡¡IInterface¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Public¡¡Overridable¡¡Sub¡¡Method£¨£©¡¡Implements¡¡IInterface¡£Method¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Console¡£WriteLine£¨¡¨Implementation¡£Method¡¨£©¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡Sub¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡Class¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Class¡¡ImplementationDerived¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Inherits¡¡Implementation¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Public¡¡Overrides¡¡Sub¡¡Method£¨£©¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Console¡£WriteLine£¨¡¨ImplementationDerived¡£Method¡¨£©¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡Sub¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡Class¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Module¡¡Test¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Public¡¡Sub¡¡Run£¨£©¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Dim¡¡implementation¡¡As¡¡ImplementationDerived¡¡=¡¡_¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡New¡¡ImplementationDerived£¨£©¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Dim¡¡inst¡¡As¡¡IInterface¡¡=¡¡implementation¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡'¡¡Calls¡¡ImplementationDerived¡£Method¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡implementation¡£Method£¨£©¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡'¡¡Calls¡¡ImplementationDerived¡£Method¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡inst¡£Method£¨£©¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡Sub¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡Module¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡o¡¡¡¡Keywords¡¡used£º¡¡Overridable¡¡and¡¡Overrides¡£¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡o¡¡¡¡By¡¡default£»¡¡when¡¡you¡¡implement¡¡an¡¡interface¡¡without¡¡using¡¡the¡¡Overridable¡¡keyword£»¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡you¡¡are¡¡saying¡¡that¡¡the¡¡derived¡¡class¡¡can¡¡overload¡¡only¡¡the¡¡method¡£¡¡In¡¡many¡¡cases£»¡¡this¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡is¡¡appropriate£»¡¡as¡¡you¡¡will¡¡want¡¡to¡¡override¡¡the¡¡method¡¡and¡¡thus¡¡will¡¡need¡¡to¡¡use¡¡the¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Overridable¡¡and¡¡Overrides¡¡keywords¡£¡¡¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡o¡¡¡¡This¡¡is¡¡a¡¡mon¡¡problem£»¡¡and¡¡most¡¡beginning¡¡Visual¡¡Basic¡¡programmers¡¡are¡¡puzz

·µ»ØĿ¼ ÉÏÒ»Ò³ ÏÂÒ»Ò³ »Øµ½¶¥²¿ ÔÞ£¨2£© ²È£¨2£©

Äã¿ÉÄÜϲ»¶µÄ