我在vb里面有两重for循环,如果满足条件,想从最里面的循环体跳出,以后所有循环语句不再执行。请问该用什么语句?

解决方案 »

  1.   

    一种方法:用GOTO 
    二种方法:巧用FOR 循环与IF判断来解决。
    不过还得看是什么业务流程!
      

  2.   

    For i = 1 To oAllProfile.Count Step 1
                For j = 1 To oAllProfile.Item(i).Count Step 1
         
                    If oEntity Is oAllProfile.Item(i).Item(j).SketchEntity Then
             
                        bFound = True    
                        n = i
                         '可以用exit for 吗?
                        GoTo go
                        
                    End If
                
                Next 
                
            Next 
             
    go:       If bFound = True Then
      

  3.   

    1、使用GoTo语句
    2、定义变量,判断。
    dim bExit as boolean
    bExit = False
    For i = 1 To oAllProfile.Count Step 1
                For j = 1 To oAllProfile.Item(i).Count Step 1
         
                    If oEntity Is oAllProfile.Item(i).Item(j).SketchEntity Then
             
                        bFound = True    
                        n = i
                         '可以用exit for 吗?
                        bExit = True
                        Exit For                End If            
                Next 
                if bExit then Exit For
            Next