PDA

View Full Version : [SOLVED] Expected end of statement error



Aussiebear
09-19-2015, 06:06 AM
All four of these lines all fail at the first occurrence of the full stop, when trying to convert time degrees to decimal degrees to radians. What have I missed?


txtRLat1.Value = "=(Left(txtLat1.Value, FIND(".",txtLat1.value)-1)+Mid(txtLat1.Value, _
FIND(".",txtLat1.Value)+1,10)/60)*PI()/180"
txtRLat2.Value = "=(Left(txtLat2.Value, FIND(".",txtLat2.value)-1)+Mid(txtLat2.Value, _
FIND(".",txtLat2.Value)+1,10)/60)*PI()/180"
txtRLong1.Value = "=(Left(txtLong1.Value, FIND(".",txtLong1.value)-1)+Mid(txtLong1.Value, _
FIND(".",txtLong1.Value)+1,10)/60)*PI()/180"
txtRLong2.Value = "=(Left(txtLong2.Value, FIND(".",txtLong2.value)-1)+Mid(txtLong2.Value, _
FIND(".",txtLong2.Value)+1,10)/60)*PI()/180"

snb
09-19-2015, 08:52 AM
what does txtLat1.value look like ?

is it a number or a string ?

Paul_Hossler
09-19-2015, 09:13 AM
You gotta double up your quote char inside a string to end up one embedded



txtRLat1.Value = "=(Left(txtLat1.Value, FIND(""."",txtLat1.value)-1)+Mid(txtLat1.Value, FIND(""."",txtLat1.Value)+1,10)/60)*PI()/180"

Aussiebear
09-19-2015, 03:43 PM
@snb it represents a time gps figure such as 23.45.435

@Paul, Yes that does the trick.

SamT
09-19-2015, 08:07 PM
Lat1.Value = CRad(DMS2Dec(txtLat1.Value, "."))


Function DMS2Dec(DMSDegree As String, Delimiter As String) As Double
Dim tmp As Variant
tmp = Split(DMSDegree, Delimiter, 3)
DMS2Dec = CDbl(tmp(0)) + CDbl(tmp(1)) / 60 + CDbl(tmp(2)) / 3600
End Function


Function CRad(DecimalDegree As Double) As Double
Const rad As Double = 3.14159265358979 / 180
CRad = DecimalDegree * rad
End Function

snb
09-20-2015, 02:40 AM
Sub M_snb()
c00 = "23.45.435"

MsgBox = Evaluate(Replace(Replace(c00, ".", "+", , 1), ".", "/60+") & "/60^2") * Application.Pi / 180
End Sub