Office Excel在工作中應(yīng)用非常廣泛,尤其是數(shù)據(jù)處理優(yōu)勢不可傾慕。
Excel VBA究竟是什么?
VBA 是 Visual Basic語言(VB)內(nèi)嵌在Office excel中的語言,V語言中最容易學(xué)懂的;應(yīng)用廣泛的辦公軟件;也是公認(rèn)的最好的數(shù)據(jù)處理平臺,作為程序的數(shù)據(jù)的輸入、輸出界面是最好不過了;在EXCEL中的計(jì)算成果數(shù)據(jù)非常方便進(jìn)行二次處理,做資料什么的都很方便;為大家介紹一段VBA 計(jì)算方位角源碼!
源碼名稱:chenchao_fwj(A,B,C,D,2)
源碼格式:chenchao_fwj(測站X,測站Y,前視X,前視Y,顯示格式)
當(dāng)顯示格式:等于-1為弧度,等于0為“DD MM SS”,等于1為“DD-MM-SS”,等于2為“DD°MMˊSS""”,等于其它值時返回十進(jìn)制度值。
Function chenchao_fwj(Sx As Double, Sy As Double, Ex As Double, Ey As Double, abcyt As Integer)
Dim DltX As Double, DltY As Double, aa As Double, Pi As Double
Pi = Atn(1) * 4
DltX = Ex - Sx
DltY = Ey - Sy + 1E-20
aa = Pi * (1 - Sgn(DltY) / 2) - Atn(DltX / DltY)
aa = aa * 180 / Pi
chenchao_fwj = FFFsky(aa, abcyt)
End Function
Function FFFsky(Deg As Double, abcyt As Integer)
Dim tD As Integer, tM As Integer, tS As Double, tmp As Double
tD = Int(Deg)
tmp = (Deg - tD) * 60
tM = Int(tmp)
tmp = (tmp - tM) * 60
tS = Round(tmp, 1)
Select Case abcyt
Case -1
FFFsky = Deg * Atn(1) * 4 / 180
Case 0
FFFsky = tD & " " & Format(tM, "00") & " " & Format(tS, "00.0")
Case 1
FFFsky = tD & "-" & Format(tM, "00") & "-" & Format(tS, "00.0")
Case 2
FFFsky = tD & "°" & Format(tM, "00") & "ˊ" & Format(tS, "00.0") & """"
Case Else
FFFsky = Deg
End Select
End Function