Dim part1,part2
Dim brgdms As String 'so main.bearingdms can be converted to string
If Main.dblBearingdms >= 0 Then
brgdms=Main.dblbearingdms 'convert to a string
brgdms=brgdms.Replace(".",",") ' replace the decimal in the number with a comma so it can be parsed
If brgdms.IndexOf (",")>0 Then 'verify the value has a decimal. Assume it has
parts=Regex.Split(",",brgdms) 'parse it
part1=parts(0) 'value in front of decimal
part2=parts(1) 'value behind decimal
End If
x= part2.IndexOf("5") 'find the index of the number 5 if present..it must be the first digit after the decimal to fit the requirement for flooring
If x=0 Then
deg=Floor(Main.dblbearingdms)
Else
deg=Round(Main.dblbearingdms)
End If
End If