repetition structurepsut重复结构的阵发性室上性心动过速课件_第1页
repetition structurepsut重复结构的阵发性室上性心动过速课件_第2页
repetition structurepsut重复结构的阵发性室上性心动过速课件_第3页
repetition structurepsut重复结构的阵发性室上性心动过速课件_第4页
repetition structurepsut重复结构的阵发性室上性心动过速课件_第5页
已阅读5页,还剩35页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

Chapter6 TheRepetitionStructure ProgrammingwithMicrosoftVisualBasic NET SecondEdition ProgrammingwithMicrosoftVisualBasic NET SecondEdition 2 TheRepetitionStructure Looping LessonAObjectives CodetherepetitionstructureusingtheFor NextandDo LoopstatementsWritepseudocodefortherepetitionstructureCreateaflowchartfortherepetitionstructureInitializeandupdatecountersandaccumulators ProgrammingwithMicrosoftVisualBasic NET SecondEdition 3 TheRepetitionStructure Usetherepetitionstructuretorepeatedlyprocessoneormoreprograminstructionsuntilsomeconditionismet atwhichtimetherepetitionendsTherepetitionstructureisreferredtoasaloop ProgrammingwithMicrosoftVisualBasic NET SecondEdition 4 TheRepetitionStructure continued Pretestloop evaluationoccursbeforetheinstructionswithintheloopareprocessedPosttestloop evaluationoccursaftertheinstructionswithintheloopareprocessed ProgrammingwithMicrosoftVisualBasic NET SecondEdition 5 TheFor NextLoop UsetheFor Nextstatementtocodealoopthatrepeatsforaspecificnumberoftimes Figure6 2 SyntaxandexamplesoftheFor Nextstatement ProgrammingwithMicrosoftVisualBasic NET SecondEdition 6 TheFor NextLoop continued Figure6 2 SyntaxandexamplesoftheFor Nextstatement continued ProgrammingwithMicrosoftVisualBasic NET SecondEdition 7 TheFor NextLoop continued counterisanumericvariablethatkeepstrackofhowmanytimestheloopinstructionsarerepeatedstartvalue endvalue andstepvalueMustbenumericCanbepositiveornegative integerornon integerDefaultstepvalueis1 ProgrammingwithMicrosoftVisualBasic NET SecondEdition 8 TheFor NextLoop continued Figure6 4 PseudocodeandflowchartforthefirstexampleshowninFigure6 2 ProgrammingwithMicrosoftVisualBasic NET SecondEdition 9 TheFor NextLoop continued For Nextloopexamples ProgrammingwithMicrosoftVisualBasic NET SecondEdition 10 TheDo LoopStatement UnliketheFor Nextstatement theDo LoopstatementcanbeusedtocodebothapretestloopandaposttestloopTheDo LoopstatementbeginswiththeDoclauseandendswiththeLoopclause ProgrammingwithMicrosoftVisualBasic NET SecondEdition 11 TheDo LoopStatement continued Figure6 7 SyntaxandexamplesoftheDo Loopstatement ProgrammingwithMicrosoftVisualBasic NET SecondEdition 12 TheDo LoopStatement continued Figure6 7 SyntaxandexamplesoftheDo Loopstatement continued ProgrammingwithMicrosoftVisualBasic NET SecondEdition 13 TheDo LoopStatement continued Figure6 9 FlowchartsfortheexamplesshowninFigure6 7 ProgrammingwithMicrosoftVisualBasic NET SecondEdition 14 TheDo LoopStatement continued Figure6 9 FlowchartsfortheexamplesshowninFigure6 7 continued ProgrammingwithMicrosoftVisualBasic NET SecondEdition 15 UsingCountersandAccumulators Countersandaccumulatorsareusedwithinarepetitionstructuretocalculatesubtotals totals andaveragesAcounterisanumericvariableusedforcountingsomethingandistypicallyupdatedby1Anaccumulatorisanumericvariableusedforaccumulatingandisupdatedbyanamountthatvaries ProgrammingwithMicrosoftVisualBasic NET SecondEdition 16 UsingCountersandAccumulators continued Initializing assigningabeginningvaluetothecounteroraccumulatorUpdating incrementing addinganumbertothevaluestoredinthecounteroraccumulator ProgrammingwithMicrosoftVisualBasic NET SecondEdition 17 NestedRepetitionStructuresLessonBObjectives Nestrepetitionstructures ProgrammingwithMicrosoftVisualBasic NET SecondEdition 18 NestingRepetitionStructures Inanestedrepetitionstructure oneloop referredtoastheinnerloop isplacedentirelywithinanotherloop calledtheouterloopAclockusesnestedloopstokeeptrackofthetime ProgrammingwithMicrosoftVisualBasic NET SecondEdition 19 NestingRepetitionStructures continued Figure6 16 Nestedloopsusedbyaclock ProgrammingwithMicrosoftVisualBasic NET SecondEdition 20 TheGradeCalculatorApplication ProfessorArkinsneedsanapplicationthatallowshimtoassignagradetoanynumberofstudentsEachstudent sgradeisbasedonthreetestscores witheachtestworth100pointsTheapplicationshouldtotalthetestscoresandthenassigntheappropriategrade usingthetableshownonthenextslide ProgrammingwithMicrosoftVisualBasic NET SecondEdition 21 TheGradeCalculatorApplication continued ProgrammingwithMicrosoftVisualBasic NET SecondEdition 22 TheGradeCalculatorApplication continued uiAssignGradeButton sClickeventprocedureAllowsProfessorArkinstoentereachstudent stestscores andthenassigntheappropriategradeContainstwoloops onenestedwithintheotherAFor Nextstatementcontrolstheinnerloop ProgrammingwithMicrosoftVisualBasic NET SecondEdition 23 TheGradeCalculatorApplication continued uiAssignGradeButton sClickeventprocedure continued ADo LoopstatementcontrolstheouterloopTheinnerloopisapretestloopTheouterloopisaposttestloop ProgrammingwithMicrosoftVisualBasic NET SecondEdition 24 TheGradeCalculatorApplication continued Figure6 20 Samplerunoftheapplicationthatcontainstheprocedure ProgrammingwithMicrosoftVisualBasic NET SecondEdition 25 CodingtheShoppersHavenApplicationLessonCObjectives SelecttheexistingtextinatextboxPreventaformfromclosing ProgrammingwithMicrosoftVisualBasic NET SecondEdition 26 ShoppersHaven ThemanagerofShoppersHavenwantsanapplicationthatthestoreclerkscanusetocalculatethediscountedpriceofanitem usingdiscountratesfrom10 through30 inincrementsof5 Theclerkswillentertheitem soriginalpriceTheapplicationshoulddisplaythediscountratesandthediscountedpricesintheinterface ProgrammingwithMicrosoftVisualBasic NET SecondEdition 27 ShoppersHaven continued Figure6 21 UserinterfacefortheShoppersHavenapplication ProgrammingwithMicrosoftVisualBasic NET SecondEdition 28 ShoppersHaven continued Figure6 22 TOEchartfortheShoppersHavenapplication ProgrammingwithMicrosoftVisualBasic NET SecondEdition 29 ShoppersHaven continued Figure6 23 PseudocodefortheCalculatebutton sClickeventprocedure ProgrammingwithMicrosoftVisualBasic NET SecondEdition 30 ShoppersHaven continued Figure6 27 DiscountedpricesshownintheShoppersHavenapplication ProgrammingwithMicrosoftVisualBasic NET SecondEdition 31 SelectingtheExistingTextinaTextBox UsetheSelectAllmethodtoselectallofthetextcontainedinatextboxSyntax textbox SelectAll textboxisthenameofthetextboxwhosetextyouwanttoselect ProgrammingwithMicrosoftVisualBasic NET SecondEdition 32 SelectingtheExistingTextinaTextBox continued EntertheSelectAllmethodinatextboxcontrol sEntereventAtextboxcontrol sEntereventoccurswhentheusertabstothecontrol andwhentheFocusmethodisusedincodetosendthefocustothecontrolTheuiOriginalTextBoxcontrol sEntereventisresponsibleforhighlightingtheexistingtextinthecontrol ProgrammingwithMicrosoftVisualBasic NET SecondEdition 33 SelectingtheExistingTextinaTextBox continued Figure6 29 TextselectedintheShoppersHavenapplication ProgrammingwithMicrosoftVisualBasic NET SecondEdition 34 CodingtheTextChangedEventProcedure Acontrol sTextChangedeventoccurswhenthecontentsofacontrol sTextpropertychangeUsetheuiOriginalTextBox sTextChangedeventtoclearthecontentsoftheuiDiscPricesLabelwhentheuserchangestheoriginalprice ProgrammingwithMicrosoftVisualBasic NET SecondEdition 35 CodingtheShoppersForm sClosingEventProcedure Aform sClosingeventoccurswhenaformisabouttobeclosedIntheShoppersHavenapplication theClosingeventprocedureisresponsiblefor VerifyingthattheuserwantstoexittheapplicationTakinganactionbasedontheuser sresponse ProgrammingwithMicrosoftVisualBasic NET SecondEdition 36 CodingtheShoppersForm sClosingEventProcedure continued Figure6 31 PseudocodefortheShoppersForm sClosingeventprocedure ProgrammingwithMicrosoftVisualBasic NET SecondEdition 37 CodingtheShoppersForm sClosingEventProcedure continued Figure6 33 Messageboxdisplayedbytheform sClosingevent ProgrammingwithMicrosoftVisualBasic NET SecondEdition 38

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论