资源描述:
《vb程序错误处理方法小结(brief summary of error handling methods for vb program)》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、vb程序错误处理方法小结(BriefsummaryoferrorhandlingmethodsforVBprogram)Youknow,evenifprogrammershavethebestintentionsandplantodoverywell,thereisnowaytoavoiderrorsinthecode.Infact,therearemanyproceduralerrorsthatmayoccur,buttheycanbasicallybedividedintotwotypes:oneiscompileerror,andt
2、heotherisruntimeerror.CompilationerrorsareerrorsthatmakethecompilerVisualBacsic(hereinafterreferredtoasVB)unabletocompilethecode.Ifthecompilererrorcontainsaprocess,VBwillnotexecutetheprocess,andwewillnotbeabletoprovideuserswithacompilationerrorintheruntimeversionoftheappl
3、ication,mostcompilationerrorscausedbysyntacticerrors.CompileoptionsforVBVBhastwosetitemsthatwillgreatlyinfluenceourabilitytocreateverysolidcode.OnesettingitemisCompileOnDemand(compiledasneeded),andtheothersettingitemisBackgroundCompile(backgroundcompilation).Youcanopenthe
4、Optionsdialogbox,selecttheGeneraltab,andthensetthetwosettingsitems,asshowninfigure1.WhenyouselectCompileOnDemand,ifyouclicktheRunbuttononthetoolbar,orpresstheF5key,VBdoesnotcompileourprojectfully.Instead,theseproceduresarecompiledonlywhenthereferenceprocessisused.UsingCom
5、pileOnDemandusuallyallowslargerprojectsorprojectsonslowercomputerstostartrunningfaster,butitcanalsocausesomeoftheneglectedcompileerrors.Beforeyoucanfindandcorrectallcompileerrors,youcan'tcompiletheprojectintoapublicationfilesuchas.Exeor.Dll,sotheCompileOnDemandisnotableto
6、publishcodewithcompileerrors.However,whentheCompileOnDemandisselected,thecompileerrorincreasesovertime,forcingustodoalotoferrorcorrectioninthefinalattempttofullycompile.IfyoudebugaprojectinIDE,VBoftenhastostop(notjustpause)torunforerrorcorrection.Thismakesdebuggingalotofc
7、ompilationerrorsverytroublesomewhendebuggingtherunningproject.Ifyoucancompiletheprojectinareasonableamountoftime,youcanconsiderclosingtheCompileOnDemand.YoucanalsokeeptheCompileOnDemandintheselectedstate,butpresstheCtrl+F5buttonperiodicallysothatwecanrerunourproject.Thisa
8、llowsustoregularlycorrectcompileerrorsinprogrammingwithouttheneedtocorrectalargeamountofcompilee