Q qey Member Mar 11, 2022 #1 Hello everyone. I have two different location A and B. For A it automatically set with current location and for B user need to insert the location. But whenever the user did not put the location which is the lat and long will become an empty string the deliverycharges will become 0. So right now i want to check if lat and long = Null Then Then deliverycharges = 0$ End If but right now it cannot make the if else condition because lat and long is not a boolean. So any idea on how to make a condition to check the value of latlong ?
Hello everyone. I have two different location A and B. For A it automatically set with current location and for B user need to insert the location. But whenever the user did not put the location which is the lat and long will become an empty string the deliverycharges will become 0. So right now i want to check if lat and long = Null Then Then deliverycharges = 0$ End If but right now it cannot make the if else condition because lat and long is not a boolean. So any idea on how to make a condition to check the value of latlong ?
E emexes Expert Licensed User Longtime User Mar 11, 2022 #2 qey said: any idea on how to make a condition to check the value of latlong ? Click to expand... Maybe something like: B4X: if IsNumber(Lat) and IsNumber(Lon) then if Lat = 0 and Lon = 0 then log("Welcome to Null Island!") else log("location looks good") end if else log("invalid or unspecified location (so delivery is free)") end or if you're happier without the Null Island reference, then: B4X: if IsNumber(Lat) and IsNumber(Lon) and (Lat <> 0 or Lon <> 0) then log("location looks good") else log("invalid or unspecified location (so delivery is free)") end Last edited: Mar 11, 2022 Upvote 0
qey said: any idea on how to make a condition to check the value of latlong ? Click to expand... Maybe something like: B4X: if IsNumber(Lat) and IsNumber(Lon) then if Lat = 0 and Lon = 0 then log("Welcome to Null Island!") else log("location looks good") end if else log("invalid or unspecified location (so delivery is free)") end or if you're happier without the Null Island reference, then: B4X: if IsNumber(Lat) and IsNumber(Lon) and (Lat <> 0 or Lon <> 0) then log("location looks good") else log("invalid or unspecified location (so delivery is free)") end
klaus Expert Licensed User Longtime User Mar 11, 2022 #3 How do you read the lat and long values. qey said: But whenever the user did not put the location which is the lat and long will become an empty string the deliverycharges will become 0. Click to expand... Where is the conversion from an empty string to zero done. When you try to convert an empty string to a number you get an error. So you should check valid lat and long values there. I would also check if the distance is realistic or not, there is probably a max range of action value which could be checked. Upvote 0
How do you read the lat and long values. qey said: But whenever the user did not put the location which is the lat and long will become an empty string the deliverycharges will become 0. Click to expand... Where is the conversion from an empty string to zero done. When you try to convert an empty string to a number you get an error. So you should check valid lat and long values there. I would also check if the distance is realistic or not, there is probably a max range of action value which could be checked.