在实际工作中会遇到k = 1.55/0情况
请问如何1/0不能被0除的情况.谢谢.
是不是只有这个解
if xx <>0 then
  k = yy/xx
end if
没有其它的办法吗?

解决方案 »

  1.   

    if xx <>0 then 
      k = yy/xx 
    end if 这种方法是最好的一种方式.如果你真要喜欢去找别的解决方式.那就加上 on error resume next只不过,用了之后,可能会发生更严重的错误.
      

  2.   

    On Error Resume Next
    Dim XX As Long,YY as long,K as long
    '输入XX
    K = YY/XX
    if  Err.Number=11 then
        msgbox("上面的除数为0了,请重新输入XX!") 
    end if
      

  3.   

     
    Dim xx As Long, k As Long, yy As Double
        yy = 1.55
        xx = 1    
        On Error GoTo errHd
        k = yy / xx
    errHd:
        Select Case Err.Number
            Case 11
                MsgBox "除数为0"
        End Select