Evaluation Bug

Discussion in 'Bug Reports' started by RacingDog, Jul 19, 2011.

  1. RacingDog

    RacingDog Active Member Licensed User

    If Value is a mesage box then

    If Value.Text = 0 Then

    works if the text is "0" but not if it is "0.00"

    Allegedly we are supposed to be able to rely on internal type conversions. This is clearly not the case at the moment.

    When will this fundamental bug be fixed?
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    This is the way it is designed to behave. When you compare a string with another value for equality it converts the value to string. The other option which is to implicitly convert the string to a number will throw an exception if the string is not a number.
    You will need to explicitly convert the string to number:
    Code:
    Dim s As String
        s = 
    "0.00"
        
    Dim n As Number
        n = s 
    'explicitly convert the string to number
        If n = 0 Then Msgbox(True)
     
  3. RacingDog

    RacingDog Active Member Licensed User

    Yes that's what I did eventually. But the numbers 0 and 0.00 should be interchangeable if the concept of automatic type changes is to be followed consistently. I don't see why converting a string and getting an exception is the run time designer's concern. That is the user's mistake and he should expect to have to handle it himself with an exception handler. Protecting the user from himself is laudable in itself, but you can over do it.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice