友情提示:如果本网页打开太慢或显示不完整,请尝试鼠标右键“刷新”本网页!阅读过程发现任何错误请告诉我们,谢谢!! 报告错误
狗狗书籍 返回本书目录 我的书架 我的书签 TXT全本下载 进入书吧 加入书签

VB2008从入门到精通(PDF格式英文版)-第55章

按键盘上方向键 ← 或 → 可快速上下翻页,按键盘上的 Enter 键可回到本书目录页,按键盘上方向键 ↑ 可回到本页顶部!
————未阅读完?加入书签已便下次继续阅读!




                       CH AP T E R   4   ■    L E A R N I N G   A B OU T   D AT A  S TR U CT U R E S;   DE CI SI ON S;   A N D   L O OP S 107 



Else  

  ' Code3 

End If 

' Code4 



     The following code steps are executed: 



     o  If test1 is True; then execute Code1。 After executing Code1; execute Code4。 



     o  If test1 is  False; jump to ElseIf with test2。 



     o  If test2 is True; then execute Code2。 After executing Code2; execute Code4。 



     o  If test2 is  False; jump to Else。 



     o  Execute Code3。 After executing Code3; execute Code4。 



     Here is another example: 



If test1 Then 

  ' Code1 

Else  

  ' Code2 

End If 

 ' Code3 



     The executed code steps are as follows: 



     o  If test1 is True; then execute Code1。 After executing Code1; execute Code3。 



     o  If test1 is  False; jump to Else。 



     o  Execute Code2。 After executing Code2; execute Code3。 



     And here is one more example: 



If test1 Then 

  ' Code1 

End If 

If test2 Then 

  ' Code2 

Else  

  ' Code3 

End If 

// Code4 



     The executed code steps are as follows: 



     o  If test1 is True; then execute Code1。 After executing Code1; jump to If with test2。 



     o  If test1 is  False; jump to If with test2。 



     o  If test2 is True; then execute Code2。 After executing Code2; execute Code4。 


…………………………………………………………Page 130……………………………………………………………

108       CH AP T E R   4   ■    L E A R N IN G   AB OU T   D AT A  S TR U CT U R E S;   DE CI SI ON S;   A N D   L O OP S 



               o  If test2 is  False; jump to Else。 



               o  Execute Code3。 After executing Code3; execute Code4。 



                The following code is illegal: 



           Else  

             ' Code2 

           End If 

           ' Code3 



                And this is also illegal: 



           ElseIf test2 Then 

             ' Code2 

           Else  

             ' Code3 

           End If 



                It is possible to have one If statement embedded within an  Else; If; or ElseIf to create a  

           more plex multilevel decision tree。 

                The condition or test'N ' variables are Boolean values that can contain True or  False。 You  

           have already seen examples of these; like this: 



           If CanContinueSearch(returnArray; currNode。Connections(c1)) Then 



                The If statement says that if the method CanContinueSearch() returns True; then execute  

           the contained code。 

                Here is another example of a condition: 



           If returnArray(c1) IsNot Nothing  Then 



                This If statement says that if the array element returnArray'(c1) does not have a value of  

           Nothing; then execute the contained code。 

                In both examples; either the method or parison must return a Boolean value。 If a Boolean  

           value is not returned; the Visual Basic piler will generate an error indicating that the code  

           does not result in a True or  False value。 

                It is easy to see how a method can generate a True or False value; but the array element not  

           equal to Nothing statement is a bit more plicated。 The statement is an example of using  

           operators to perform a parison。 parisons test if things are equal to each other or not  

           equal to each other。 Table 4…2 shows the parison operators and what they mean。  



           Table 4…2。  parison Operators 



           Expression          Description 



           a = b               Does a equal  b? 



           a  b              Does a not equal  b? 



           a 》 b               Is a greater than b? 



           a 《 b               Is a less than  b? 


…………………………………………………………Page 131……………………………………………………………

                        CH AP T E R   4   ■    L E A R N I N G   A B OU T   D AT A  S TR U CT U R E S;   DE CI SI ON S;   A N D   L O OP S 109 



Table 4…2。  parison Operators 



Expression           Description 



a 》= b               Is a greater than or equal to b? 



a 
返回目录 上一页 下一页 回到顶部 0 0
未阅读完?加入书签已便下次继续阅读!
温馨提示: 温看小说的同时发表评论,说出自己的看法和其它小伙伴们分享也不错哦!发表书评还可以获得积分和经验奖励,认真写原创书评 被采纳为精评可以获得大量金币、积分和经验奖励哦!