ลองทำ poi sygic เอง พาหลงเลยกว่าจะเจอสาเหตุว่ามาจาก E8°06'00.4"N 98°59'05.4" องศาทศนิยม poi sygic ต้องเป็นแบบนี้ 100.532713 20.016789
ได้แล้วครับบบบบ ขอบคุณทุกท่านครับ
วิธีการแปลงค่าระหว่างองศา/นาที/วินาที/มุมและมุมทศนิยมใน Excel
การแปลงองศาทศนิยมไปเป็นองศา/นาที/วินาที
ฟังก์ชันที่กำหนดเองต่อไปนี้ของ Microsoft Visual Basic สำหรับแอปพลิเคชันยอมรับมุมซึ่งจัดรูปแบบเป็นค่าทศนิยม และแปลงไปเป็นค่าข้อความที่แสดงในหน่วยองศา นาที และวินาที
Function Convert_Degree(Decimal_Deg) As Variant
With Application
'Set degree to Integer of Argument Passed
Degrees = Int(Decimal_Deg)
'Set minutes to 60 times the number to the right
'of the decimal for the variable Decimal_Deg
Minutes = (Decimal_Deg - Degrees) * 60
'Set seconds to 60 times the number to the right of the
'decimal for the variable Minute
Seconds = Format(((Minutes - Int(Minutes)) * 60), "0")
'Returns the Result of degree conversion
'(for example, 10.46 = 10~ 27 ' 36")
Convert_Degree = " " & Degrees & "° " & Int(Minutes) & "' " _
& Seconds + Chr(34)
End With
End Function
เมื่อต้องการใช้ฟังก์ชันนี้ ให้สร้างสูตรการแปลง เช่น ในตัวอย่างต่อไปนี้:
เริ่ม Excel แล้วกด ALT+F11 เพื่อเริ่ม Visual Basic Editor
ในเมนู แทรก คลิก โมดูล
ใส่รหัสตัวอย่างสำหรับฟังก์ชันที่กำหนดเอง Convert_Degree ตามที่อธิบายข้างต้นลงในแผ่นงานโมดูล
กด ALT+F11 เพื่อกลับไปยัง Excel
ในเซลล์ A1 พิมพ์ 10.46
ในเซลล์ A2 พิมพ์สูตรต่อไปนี้:
=Convert_Degree(A1)
สูตรจะส่งกลับผลลัพธ์ 10°27'36"
การแปลงองศาทศนิยมไปเป็นองศา/นาที/วินาที
ฟังก์ชันที่กำหนดเองต่อไปนี้ของ Microsoft Visual Basic สำหรับแอปพลิเคชันยอมรับสตริงข้อความที่เป็นมุม นาที และวินาทีซึ่งจัดรูปแบบในรูปแบบเดียวกับผลลัพธ์ที่ฟังก์ชัน Convert_Degree ส่งกลับมา (เช่น 10° 27' 36") และแปลงไปเป็นมุมที่จัดรูปแบบเป็นค่าทศนิยม นี่เป็นการย้อนกลับของฟังก์ชันที่กำหนดเอง Convert_Degree
คำเตือน: ฟังก์ชันที่กำหนดเองนี้จะล้มเหลวถ้าอาร์กิวเมนต์ Degree_Deg ไม่ได้อยู่ในรูปแบบต่อไปนี้
<องศา>° <นาที>' <วินาที>"
แม้ว่าค่าวินาทีจะเป็น 0 ก็ตาม
Function Convert_Decimal(Degree_Deg As String) As Double
' Declare the variables to be double precision floating-point.
Dim degrees As Double
Dim minutes As Double
Dim seconds As Double
' Set degree to value before "°" of Argument Passed.
degrees = Val(Left(Degree_Deg, InStr(1, Degree_Deg, "°") - 1))
' Set minutes to the value between the "°" and the "'"
' of the text string for the variable Degree_Deg divided by
' 60. The Val function converts the text string to a number.
minutes = Val(Mid(Degree_Deg, InStr(1, Degree_Deg, "°") + 2, _
InStr(1, Degree_Deg, "'") - InStr(1, Degree_Deg, _
"°") - 2)) / 60
' Set seconds to the number to the right of "'" that is
' converted to a value and then divided by 3600.
seconds = Val(Mid(Degree_Deg, InStr(1, Degree_Deg, "'") + _
2, Len(Degree_Deg) - InStr(1, Degree_Deg, "'") - 2)) _
/ 3600
Convert_Decimal = degrees + minutes + seconds
End Function
เมื่อต้องการใช้ฟังก์ชันนี้ ให้สร้างสูตรการแปลง เช่น ในตัวอย่างต่อไปนี้:
เริ่ม Excel แล้วกด ALT+F11 เพื่อเริ่ม Visual Basic Editor
ในเมนู แทรก คลิก โมดูล
ใส่รหัสตัวอย่างสำหรับฟังก์ชันที่กำหนดเอง Convert_Decimal ตามที่อธิบายข้างต้นลงในแผ่นงานโมดูล
กด ALT+F11 เพื่อกลับไปยัง Excel
ในเซลล์ A1 พิมพ์สูตรต่อไปนี้:
=Convert_Decimal("10° 27' 36""")
หมายเหตุ: คุณจะต้องพิมพ์สามเครื่องหมายคำพูด (""") ที่ส่วนท้ายของอาร์กิวเมนต์ของสูตรนี้เพื่อความสมดุลของเครื่องหมายคำพูดสำหรับวินาที และเครื่องหมายคำพูดสำหรับสตริงข้อความ การอ้างอิงเซลล์ไม่จำเป็นต้องมีเครื่องหมายคำพูด
สูตรจะส่งกลับผลลัพธ์เท่ากับ 10.46