Sub form_click() Dim i, num Do For i = 1 To 1000 num = Int(Rnd * 100) Print num; Select Case num Case 7: Exit For Case 29: Exit Do Case 54: Exit Sub End Select Next i Print "exit for" Loop Print "exit do"
Private Sub Form_Click() Dim i, num Randomize '初始化随机种子,不然你每次都是一样的效果。 Do For i = 1 To 1000 num = Int(Rnd * 100) Print num; Select Case num Case 7: Exit For Case 29: Exit Do Case 54: Exit Sub End Select Next i Print "exit for" Loop Print "exit do"