Problem with function
To briefly explain what I am doing: I am taking lat and longatude values EG 34 54.5N , 139 24.5E These values are required to be stored as integers (allows for searching coords etc) I apply a calculation to them to make them integers, they end up as either positive integers (Lat East ot Long north values) or negative integers (Lat West or Long South values)
(LAT) 34 54.5N gets stored as 20945
(LONG)139 24.5E gets stored as 83645
When I display the numbers I reverse the calculation using two functions:
function latToString(intValue)
dim nORs
nORs = "N"
if int(intValue) < 0 then
nORs = "S"
latToString = abs(latToString)
end if
latToString = fix(intValue / 600) & " " & ((intValue mod 600) / 10) & nORs
end function
function longToString(intValue)
dim eORw
eORw = "E"
if int(intValue) < 0 then
eORw = "W"
longToString = abs(longToString)
end if
longToString = fix(intValue / 600) & " " & ((intValue mod 600) / 10) & eORw
end function
When I pass 20945 into the latToString function it returns the value it should: 34 54.5N
When I pass 83645 into the longToString function it returns the figures it should however they are negative numbers: -139 -24.5W
From what I can see I am using the abs function correctly, can anybody spot what I am doing wrong?
TYIA
Wind is your friend
Matt
__________________
Wind is your friend
Matt
|