View Full Version : Setting text format for a textbook on a form
Aussiebear
09-19-2015, 01:54 AM
How does one set the format for a textbox on a form to accept either time degrees or decimal degrees?
A TextBox holds text, String Values.
TextBox1.Value = CStr(DecimalDegreeNumber)
TextBox2.Value = Degrees & "*:" & Minutes & "':" & Seconds & """
TextBox1 reads as : 150.82375927
TextBox2 reads as: 150*:13':34.395"
Aussiebear
09-19-2015, 06:14 AM
Hmmm, what about if I wanted to put a cat amongst the pidgeons by only wanting Degrees &"." & Minutes &"." & Seconds in the form of
23.45.789 or 150.56.345
did you try
format(2345789,"@@@.@@.@@@")
Aussiebear
09-19-2015, 03:46 PM
@snb, I did try to write it as txtLatitude1.Value = Format(txtLatitude1.Value, "00.00.000") but haven't tested it yet.
Hmmm, what about if I wanted to put a cat amongst the pidgeons by only wanting Degrees &"." & Minutes &"." & Seconds in the form of
23.45.789 or 150.56.345
Use Left(CStr(Seconds * 10), 3)
If the starting value is Decimal degrees, you will have to convert it to Degrees, Minutes Seconds.
By definition, in D:M:S Nomenclature, Degrees are integers from 0 to 359 or from -179 to +179, Minutes are integers from 0 to 59, and seconds are doubles from 0 to 59.999...
For decimal Degrees, Degrees are doubles from -179.999... to +179.999...
Thought Experiment:
Function ConvertToDMS(DecDegree As Double) As Variant
Dim NegativeSign As Boolean
'DecDegree is Double
Dim dmsDegree As Int
Dim DecMinute As Double
Dim dmsMinute As Int
Dim dmsSecond As Double
NegativeSign = DecDegree < 0
If NegativeSign then DecDegree = DecDegree * -1
dmsDegree = Int(DecDegree)
DecMinute = DecDegree - dmsDegree
dmsMinute = Int(DecMinute * 60)
dmsSecond = (DecMinute - dmsMinute) * 60
If NegativeSign Then dmsDegree = dmsDegree * -1
ConvertToDMS = Array(dmsDegree, dmsMinute, dmsSecond)
End Function
I changed the format in #4 to format(y,"@@@.@@.@@@")
Paul_Hossler
09-21-2015, 10:17 AM
@SamT
For decimal Degrees, Degrees are doubles from -179.999... to +179.999...
Not for latitudes of course
Paul_Hossler
09-21-2015, 04:04 PM
:devil2:
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.