°´¼üÅÌÉÏ·½Ïò¼ü ¡û »ò ¡ú ¿É¿ìËÙÉÏÏ·ҳ£¬°´¼üÅÌÉ쵀 Enter ¼ü¿É»Øµ½±¾ÊéĿ¼ҳ£¬°´¼üÅÌÉÏ·½Ïò¼ü ¡ü ¿É»Øµ½±¾Ò³¶¥²¿£¡
¡ª¡ª¡ª¡ªÎ´ÔĶÁÍꣿ¼ÓÈëÊéÇ©ÒѱãÏ´μÌÐøÔĶÁ£¡
know¡¡about¡¡when¡¡writing¡¡your¡¡own¡¡code¡£¡¡
More¡¡Preprocessor¡¡Directive¡¡Details¡¡
Earlier¡¡in¡¡the¡¡chapter£»¡¡you¡¡saw¡¡how¡¡you¡¡can¡¡use¡¡the¡¡hash¡¡character¡¡£¨#£©¡¡and¡¡conditional¡¡state
ments¡¡to¡¡conditionally¡¡include¡¡code¡¡during¡¡pilation¡£¡¡The¡¡technical¡¡term¡¡for¡¡this¡¡jargon¡¡is¡¡¡¡
called¡¡preprocessing¡¡the¡¡code£»¡¡and¡¡the¡¡statements¡¡are¡¡called¡¡¡¡preprocessor¡¡directives¡£¡¡Table¡¡6¡1¡¡¡¡
shows¡¡the¡¡preprocessor¡¡directives¡¡you¡¡can¡¡use¡£¡¡
Table¡¡6¡1¡£¡¡Available¡¡Preprocessor¡¡Directives¡¡
Hash¡¡Code¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Description¡¡
#Const¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Used¡¡to¡¡define¡¡the¡¡pilation¡¡identifier£»¡¡such¡¡as¡¡the¡¡INTEGRATE_TESTS¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡identifier¡¡used¡¡in¡¡this¡¡chapter¡¯s¡¡example¡£¡¡You¡¡would¡¡define¡¡this¡¡at¡¡the¡¡top¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡of¡¡a¡¡source¡¡code¡¡file¡¡to¡¡activate¡¡conditional¡¡preprocessor¡¡statements¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡used¡¡throughout¡¡the¡¡source¡¡code¡¡file¡£¡¡Using¡¡a¡¡#Const¡¡directive¡¡does¡¡not¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡span¡¡multiple¡¡source¡¡code¡¡files¡£¡¡
#If¡¡and¡¡#End¡¡If¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Used¡¡to¡¡conditionally¡¡include¡¡or¡¡not¡¡include¡¡a¡¡piece¡¡of¡¡source¡¡code¡£¡¡You¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡would¡¡use¡¡a¡¡conditional¡¡directive¡¡whenever¡¡you¡¡wanted¡¡to¡¡define¡¡source¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡code¡¡configurations£»¡¡such¡¡as¡¡for¡¡debug¡¡or¡¡production¡¡builds¡£¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Page¡¡180¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡
158¡¡¡¡¡¡¡¡¡¡¡¡¡¡CH¡¡AP¡¡T¡¡E¡¡R¡¡¡¡¡¡6¡¡¡¡¡¡¡ö¡¡¡¡¡¡¡¡L¡¡E¡¡A¡¡R¡¡N¡¡IN¡¡G¡¡¡¡¡¡T¡¡HE¡¡¡¡¡¡B¡¡AS¡¡IC¡¡S¡¡¡¡O¡¡F¡¡¡¡¡¡OB¡¡J¡¡E¡¡CT¡¡OR¡¡I¡¡E¡¡N¡¡T¡¡E¡¡D¡¡¡¡¡¡P¡¡R¡¡O¡¡G¡¡R¡¡AM¡¡M¡¡IN¡¡G¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Table¡¡6¡1¡£¡¡Available¡¡Preprocessor¡¡Directives¡¡£¨Continued£©¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Hash¡¡Code¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Description¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡#ElseIf¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Instead¡¡of¡¡a¡¡single¡¡#If¡¡block£»¡¡you¡¡could¡¡have¡¡multiple¡¡tests¡¡for¡¡code¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡inclusion¡£¡¡You¡¡would¡¡use¡¡#ElseIf¡¡when¡¡you¡¡have¡¡more¡¡than¡¡a¡¡single¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡preprocessor¡¡directive£»¡¡such¡¡as¡¡for¡¡debug£»¡¡production£»¡¡and¡¡performance¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡builds¡£¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡#Else¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡A¡¡default¡¡code¡¡block¡¡that¡¡is¡¡included¡¡if¡¡the¡¡other¡¡#If¡¡statements¡¡did¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡not¡¡trigger¡£¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡#Region¡¡and¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡These¡¡have¡¡absolutely¡¡nothing¡¡to¡¡do¡¡with¡¡the¡¡pilation¡¡of¡¡the¡¡source¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡#EndRegion¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡code¡£¡¡They¡¡are¡¡used¡¡by¡¡Visual¡¡Studio¡¡to¡¡create¡¡regions¡¡of¡¡source¡¡code¡¡that¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡can¡¡be¡¡¡°folded¡£¡±¡¡Folding¡¡means¡¡to¡¡collapse¡¡a¡¡block¡¡code¡¡out¡¡of¡¡sight¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡temporarily¡£¡¡Source¡¡code¡¡files¡¡can¡¡be¡¡bee¡¡long£»¡¡and¡¡constantly¡¡paging¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡up¡¡and¡¡down¡¡bees¡¡tedious¡£¡¡By¡¡folding¡¡the¡¡code£»¡¡you¡¡are¡¡reducing¡¡the¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡amount¡¡of¡¡times¡¡that¡¡you¡¡need¡¡to¡¡page¡¡up¡¡and¡¡down£»¡¡even¡¡though¡¡the¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡code¡¡still¡¡exists¡£¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡The¡¡following¡¡example¡¡demonstrates¡¡how¡¡to¡¡use¡¡the¡¡preprocessor¡¡directives¡£¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡#Const¡¡ACTIVATE_1¡¡=¡¡True¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Namespace¡¡TestDefine¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Class¡¡Example¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡#If¡¡ACTIVATE_1¡¡Then¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Private¡¡_dataMember¡¡As¡¡Integer¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡#ElseIf¡¡Not¡¡NO_ACTIVATE_10¡¡Then¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Private¡¡_dataMember3¡¡As¡¡Integer¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡#Else¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Private¡¡_defaultValue¡¡As¡¡Integer¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡#End¡¡If¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡Class¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡Namespace¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡In¡¡general£»¡¡you¡¡will¡¡use¡¡preprocessor¡¡directives¡¡when¡¡you¡¡are¡¡building¡¡debug¡¡mode¡¡or¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡release¡¡mode¡¡code¡£¡¡Debug¡¡mode¡¡means¡¡that¡¡the¡¡code¡¡is¡¡piled¡¡such¡¡that¡¡it¡¡can¡¡be¡¡debugged¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡and¡¡analyzed¡¡using¡¡pretty¡¡symbols¡£¡¡Release¡¡mode¡¡means¡¡when¡¡the¡¡code¡¡is¡¡piled£»¡¡the¡¡code¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡can¡¡still¡¡be¡¡debugged£»¡¡but¡¡the¡¡pretty¡¡symbols¡¡are¡¡missing¡£¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡öNote¡¡¡¡Visual¡¡Basic¡¡Express¡¡does¡¡not¡¡give¡¡you¡¡the¡¡flexibility¡¡to¡¡choose¡¡debug¡¡mode¡¡or¡¡release¡¡mode¡¡for¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡development¡£¡¡To¡¡get¡¡this¡¡feature£»¡¡you¡¡need¡¡the¡¡full¡¡version¡¡of¡¡Visual¡¡Studio¡£¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Think¡¡of¡¡the¡¡pretty¡¡symbols¡¡as¡¡milestones¡¡on¡¡the¡¡road¡£¡¡Every¡¡time¡¡your¡¡code¡¡executes¡¡in¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡debug¡¡mode£»¡¡the¡¡code¡¡is¡¡saying£»¡¡¡°You¡¡are¡¡now¡¡calling¡¡this¡¡method¡¡in¡¡this¡¡source¡¡code¡¡file£»¡±¡¡or¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡°Oops£»¡¡that¡¡property¡¡code¡¡in¡¡the¡¡source¡¡code¡¡file¡¡is¡¡not¡¡working¡¡properly¡£¡±¡¡In¡¡release¡¡mode£»¡¡the¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡pretty¡¡symbols¡¡are¡¡more¡¡like¡¡road¡¡signs¡¡saying£»¡¡¡°Place¡¡X¡¡y¡¡Miles/Kilometers¡£¡±¡¡The¡¡signs¡¡help¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Page¡¡181¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡CH¡¡A¡¡PT¡¡E¡¡R¡¡¡¡¡¡6¡¡¡¡¡¡¡ö¡¡¡¡¡¡¡¡L¡¡E¡¡A¡¡R¡¡N¡¡I¡¡N¡¡G¡¡¡¡¡¡T¡¡HE¡¡¡¡¡¡B¡¡AS¡¡IC¡¡S¡¡¡¡O¡¡F¡¡¡¡¡¡O¡¡B¡¡J¡¡E¡¡CT¡¡OR¡¡I¡¡E¡¡N¡¡TE¡¡D¡¡¡¡¡¡P¡¡R¡¡O¡¡G¡¡R¡¡AM¡¡M¡¡IN¡¡G¡¡159¡¡
guide¡¡you£»¡¡but¡¡the¡¡information¡¡you¡¡get¡¡from¡¡them¡¡is¡¡very¡¡limited£»¡¡that¡¡is£»¡¡you¡¡don¡¯t¡¡know¡¡which¡¡¡¡
towns¡¡you¡¯re¡¡passing¡£¡¡
More¡¡Property¡¡Scope¡¡Details¡¡
In¡¡this¡¡chapter¡¯s¡¡examples£»¡¡the¡¡Get¡¡and¡¡Set¡¡parts¡¡of¡¡the¡¡properties¡¡always¡¡had¡¡the¡¡same¡¡scope¡£¡¡¡¡
However£»¡¡properties¡¡can¡¡have¡¡mixed¡¡scope£»¡¡that¡¡is£»¡¡the¡¡Get¡¡and¡¡Set¡¡parts¡¡can¡¡have¡¡different¡¡¡¡
scopes¡£¡¡Scope¡¡splitting¡¡works¡¡only¡¡if¡¡you¡¡specify¡¡both¡¡the¡¡Get¡¡and¡¡Set¡¡parts¡¡of¡¡the¡¡property¡£¡¡The¡¡¡¡
idea¡¡behind¡¡splitting¡¡the¡¡scope¡¡is¡¡to¡¡enable¡¡the¡¡implementation¡¡of¡¡the¡¡logic¡¡where¡¡classes¡¡in¡¡the¡¡¡¡
inheritance¡¡chain¡¡are¡¡allowed¡¡to¡¡assign¡¡a¡¡property£»¡¡and¡¡classes¡¡external¡¡to¡¡the¡¡inheritance¡¡¡¡
chain¡¡are¡¡allowed¡¡only¡¡to¡¡read¡¡the¡¡property¡£¡¡The¡¡following¡¡is¡¡an¡¡example¡¡where¡¡a¡¡property¡¡is¡¡¡¡
declared¡¡as¡¡Public¡¡and¡¡the¡¡assignment¡¡of¡¡the¡¡property¡¡is¡¡¡¡Protected¡£¡¡
Class¡¡PropertyScopeExample¡¡
¡¡¡¡¡¡¡¡Private¡¡_value¡¡As¡¡Integer¡¡
¡¡¡¡¡¡¡¡Public¡¡Property¡¡Value£¨£©¡¡As¡¡Integer¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Protected¡¡Set£¨ByVal¡¡value¡¡As¡¡Integer£©¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡_value¡¡=¡¡value¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡Set¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Get¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Return¡¡_value¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡Get¡¡
¡¡¡¡¡¡¡¡End¡¡Property¡¡
End¡¡Class¡¡
The¡¡MustOverride¡¡Keyword¡¡
In¡¡this¡¡chapter¡¯s¡¡example£»¡¡the¡¡keyword¡¡MustInherit¡¡was¡¡used¡¡to¡¡declare¡¡a¡¡class¡¡that¡¡could¡¡be¡¡¡¡
referenced£»¡¡but¡¡not¡¡instantiated¡£¡¡It¡¡is¡¡also¡¡possible¡¡to¡¡define¡¡methods¡¡that¡¡need¡¡to¡¡be¡¡imple
mented¡£¡¡In¡¡Visual¡¡Basic£»¡¡to¡¡require¡¡a¡¡derived¡¡cl