Hi David
Please help....I am doing something stupid:
Sub LatLonFromString (s,NorthEast)
Select frmt
Case 0
arr() = StrSplit(s,":")
If ArrayLen(arr()) <> 3 Then Return 0
Return NorthEast*(arr(0) + arr(1) / 60 + arr(2) / 3600)
Case 1
arr() = StrSplit(s,":")
If ArrayLen(arr()) <> 3 Then Return 0
Return NorthEast*(arr(0) + arr(1) / 60 + arr(2) / 6000)
Case 2
If IsNumber(s) Then Return NorthEast*s Else Return 0
End Select
End Sub
'Returns a string from the Lat or Lon value (using the right format).
Sub StringFromLatLon (ll1)
Dim a,b,c
ErrorLabel (errStringFromLatLon)
ll1 = Abs(ll1)
a = Int(ll1)
b = Int((ll1-a) * 60)
c = Round ((ll1 - a - b / 60) * 3600)
If c >= 60 Then
b = b + 1
c = c - 60
End If
If b >= 60 Then
a = a + 1
b = b - 60
End If
Return Format(a,"d2") & ":" & Format(b,"d2") & ":" & Format(c,"d2")
errStringFromLatLon:
Return "0"
End Sub
Sub cmbDatum_SelectionChanged (Index, Value)
ErrorLabel(cmbDatum_err)
Textbox115.Text=Datums(index).Name
If Index = datum Then Return
dx = Datums(datum).Dx - Datums(index).Dx
dy = Datums(datum).Dy - Datums(index).Dy
dz = Datums(datum).Dz - Datums(index).Dz
If north = 1 Then n = True Else n = False
ll() = Gpsconverter.UTMToLatLon(Datums(datum).Axis, Datums(datum).F,txtXZone.Text,txtUTMx.Text,n,txtUTMy.Text)
ll() = Gpsconverter.ChangeDatum(ll.Lat,ll.Lon, Datums(datum).Axis,Datums(datum).F,Datums(index).Axis,Datums(index).F,dx,dy,dz)
UTM() = Gpsconverter.LatLonToUTM(Datums(index).Axis,Datums(index).F,ll.Lat,ll.Lon)
txtXZone.Text = UTM.XZone
txtUTMx.Text = Int(UTM.X)
txtUTMy.Text = Int(UTM.Y)
ll.Lat = LatLonFromString(txtLat.Text,north)
ll.Lon = LatLonFromString(txtLon.Text,east)
ll() = Gpsconverter.ChangeDatum(ll.Lat,ll.Lon, Datums(datum).Axis,Datums(datum).F,Datums(index).Axis,Datums(index).F,dx,dy,dz)
txtLat.Text = StringFromLatLon(ll.Lat)
txtLon.Text = StringFromLatLon(ll.Lon)
datum = index
cmbDatum_err:
End Sub
Sub cmbZone_SelectionChanged (Index, Value)
Select Index
Case 0 'NE
north = 1
east = 1
Case 1 'NW
north = 1
east = -1
Case 2 'SE
north = -1
east = 1
Case 3 'SW
north = -1
east = -1
End Select
If north = 1 Then Label9.Text = "N" Else Label9.Text = "S"
If east = 1 Then Label10.Text = "E" Else Label10.Text = "W"
End Sub
Sub CalcLatLong_Click
'ErrorLabel(btnToLL_err)
If Code1=1 Then
'Grid To Lat\Long
If north = 1 Then n = True Else n = False
If IsNumber(txtXZone.Text)=False Then txtXZone.Text=17
If Textbox115.Text<>"WGS84" Then
LL() = Gpsconverter.UTMToLatLon(Datums(datum).Axis,Datums(datum).F,txtXZone.Text,txtUTMx.Text,n,txtUTMy.Text)
Else
LL() = Gpsconverter.WGS84UTMToLatLon (txtXZone.Text, txtUTMy.Text, n, txtUTMx.Text)
End If
txtLat.Text = StringFromLatLon(LL.Lat)
txtLon.Text = StringFromLatLon(LL.Lon)
Else
'LatLong To Grid
If Textbox115.Text<>"WGS84" Then
UTM() = Gpsconverter.LatLonToUTM(Datums(datum).Axis,Datums(datum).F,LatLonFromString(txtLat.Text,north), LatLonFromString(txtLon.Text,east))
Else
'll.lat=LatLonFromString(txtLat.Text,north):ll.lon=LatLonFromString(txtLon.Text,east)
'UTM()=Gpsconverter.WGS84LatLonToUTM (ll.lat,ll.lon)
utm() = gpsConverter.LatLonToUTM(Datums(datum).Axis,Datums(datum).F ,point.geo_lat,point.geo_long)
'point.sector = utm.Xsector
point.utm_x = utm.X
point.utm_y = utm.Y
End If
Msgbox(utm.X & " " & utm.Y)
txtXZone.Text = UTM.XZone
txtUTMx.Text = Round(UTM.X)
txtUTMy.Text = Round(UTM.Y)
End If
btnToLL_err:
End Sub
Sub TxtLat_Keypress(Keypress)
If Keypress=Chr(13) Then
TxtLat.IgnoreKey
point.geo_lat=TxtLat.Text
TxtLon.Focus
End If
End Sub
Sub TxtLon_Keypress(Keypress)
If Keypress=Chr(13) Then
TxtLon.IgnoreKey
point.geo_long=TxtLon.Text
CalcLatLong.Focus
End If
End Sub
Sub TxtUTMx_Keypress(Keypress)
If Keypress=Chr(13) Then
TxtUTMx.IgnoreKey
TxtUTMy.Focus
End If
End Sub
Sub TxtUTMy_Keypress(Keypress)
If Keypress=Chr(13) Then
TxtUTMy.IgnoreKey
CalcLatLong.Focus
End If
End Sub
Sub ExitLatLong_Click
LatLong.Close
End Sub
Thanks
Michael