Android Question If then and callsub

Nickelgrass

Active Member
Licensed User
Longtime User
Hello,
I get a warning 35 when I do this:

If CallSub(service_name, "foo") = 5 Then

but not this

If 5 = If CallSub(service_name, "foo") Then

foo returns an int. Whats the difference?

Thanks
 

agraham

Expert
Licensed User
Longtime User
The left hand term of an If ... Then expression determines the type of the comparison. In the case of CallSub the exact return type is not known as it returns a generic Object. You should have got this message which tells you what to do.
Main - 35: Comparison of Object to other types will fail if exact types do not match.
Better to put the object on the right side of the comparison. (warning #35)
 
Upvote 1

Star-Dust

Expert
Licensed User
Longtime User
B4X:
If CallSub(service_name, "foo").As(Int) = 5 Then
So do you understand?
 
Upvote 0
Top