Evaluation Bug

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?
 

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:
B4X:
    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)
 

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.
 
Top