exit sub 当然退出的是该语句所在的sub了要全部退出就用  END 结束本进程

解决方案 »

  1.   

    You can do this way.
    Declare a function named ValidateText return Boolean.Private Function ValidateText As Boolean
      'Init ValidateText
      ValidateText = False(Thie statement can be omited)
       If Txt_Q = "" Then
           MsgBox "必须录入!", , "检查输入"
           Exit Function
        End If
      '...
      ValidateText = True
    End FunctionPrivate Sub Command1_Click()
      If ValidateText = False then Exit Sub
    End Sub
      

  2.   

    Private Sub Command1_Click()
    If Txt_Q = "" Then
                    MsgBox "必须录入!", , "检查输入"
                    Exit Sub
                End If
                 If Txt选项(0) = "" Then
                    MsgBox "不能为空!", , "检查输入"
                    Exit Sub
                End If
                If Txt选项(1) = "" Then
                    MsgBox "不能为空!", , "检查输入"
                    Exit Sub
                End If
                If Txt选项(2) = "" Then
                    MsgBox "不能为空!", , "检查输入"
                    Exit Sub
                End If
                If Txt选项(3) = "" And Txt选项(4) <> "" Then
                    MsgBox "不能为空!", , "检查输入"
                    Exit Sub
                End If
    End Sub
      

  3.   

    private sub command1_click()
        a=false
         a=test()
         if a = false then exit sub
         a=10
         b=20
         ...
     end sub
    过程为
           private Function test() as boolean
               If Txt_Q = "" Then
                    MsgBox "必须录入!", , "检查输入"
                    Exit Function 
                End If
                 If Txt选项(0) = "" Then
                    MsgBox "不能为空!", , "检查输入"
                    Exit Function 
                End If
                If Txt选项(1) = "" Then
                    MsgBox "不能为空!", , "检查输入"
                    Exit Function 
                End If
                If Txt选项(2) = "" Then
                    MsgBox "不能为空!", , "检查输入"
                    Exit Sub
                End If
                If Txt选项(3) = "" And Txt选项(4) <> "" Then
                    MsgBox "不能为空!", , "检查输入"
                    Exit Function 
                End If
              test=true
           end Function 
      

  4.   

    wxy_xiaoyu(☆然也☆╭∩╮(︶︿︶)╭∩╮) 只想混分而已。
      

  5.   

    楼上的我看end也不是楼主要的效果
    exit sub只是退出当前过程,你的要求可以定义函数,假如只要有个文本框为空就返回false,否则返回true,可以如下:
    private Function test() as Boolean
               If Txt_Q = "" Then
                    MsgBox "必须录入!", , "检查输入"
                    text=False
                    Exit Function
                End If
                 If Txt选项(0) = "" Then
                    MsgBox "不能为空!", , "检查输入"
                    text=False
                    Exit Function
                End If
                If Txt选项(1) = "" Then
                    MsgBox "不能为空!", , "检查输入"
                    text=False
                    Exit Function
                End If
                If Txt选项(2) = "" Then
                    MsgBox "不能为空!", , "检查输入"
                    text=False
                    Exit Function
                End If
                If Txt选项(3) = "" And Txt选项(4) <> "" Then
                    MsgBox "不能为空!", , "检查输入"
                    text=False
                    Exit Function
                End If
                test=true
           end Function然后这样调用
    private sub command1_click()
         if not test() then exit sub
         a=10
         b=20
         ...
     end sub
      

  6.   

    将此过程改写为一函数。Private Function test() As Boolean
      If Txt_Q = "" Then
         MsgBox "必须录入!", , "检查输入"
         test=False  '每个if都要加上这句
         Exit Sub
       End If
      If Txt选项(0) = "" Then
         MsgBox "不能为空!", , "检查输入"
         test=False
         Exit Sub    
     ……………………
    End Function然后在
    private sub command1_click()
       
       if test=False then  
          exit sub
        End if     a=10
         b=20
         ...
     end sub你试试看!