明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2077|回复: 1

[求助]求高手帮助修改一下代码

[复制链接]
发表于 2008-5-30 21:58 | 显示全部楼层 |阅读模式
[求助]求高手帮助修改一下代码

这是一个工程测量平差代码,调试时出现错误。麻烦各位高手查看并修改一下,小弟在这里不胜感激。

Public Const pi = 3.14159265359
Public Function DEG(n As Double)
Dim A As Double, B As Double, C As Double, D As Double, E As Double, F As Double, G As Double, KA As Double
D = Abs(n) + 0.000000000000001
F = Sgn(n)
A = Int(D)
B = Int((D - A) * 100)
C = D - A - B / 100
DEG = F * (A + B / 60 + C / 0.36) * pi / 180
End Function

Sub附合导线计算()
Dim m As Integer, n As Integer, ms As Double, gg As Double, sht As Object, xx As Double, yy As Double, S As Double
Set sht = ThisWorkbook.ActiveSheet
Do While sht.Cells(m + 3, 4) <> ""
m = m + 1
Loop
For n = 3 To m + 2
ms = DEG(ms) + DEG(sht.Cells(n, 4))
ms = RAD(ms)
S = S + sht.Cells(n, 3)
Next
ms = DEG(ms)
gg = RAD(DEG(sht.Cells(3, 5)) + ms - DEG(sht.Cells(3 + m, 5)) - pi * m)
xx = 0: yy = 0
For n = 4 To m + 2
'方位角
sht.Cells(n, 5) = RAD(DEG(sht.Cells(n - 1, 5)) + DEG(sht.Cells(n - 1, 4)) - pi - DEG(gg) / m)
'坐标增量
sht.Cells(n, 6) = Format(sht.Cells(n - 1, 3) * Cos(DEG(sht.Cells(n, 5))), "#####.####")
sht.Cells(n, 7) = Format(sht.Cells(n - 1, 3) * Sin(DEG(sht.Cells(n, 5))), "#####.####")
'坐标增量和
xx = xx + sht.Cells(n, 6)
yy = yy + sht.Cells(n, 7)
Next
xx = xx + sht.Cells(3, 10) - sht.Cells(m + 2, 10)
yy = yy + sht.Cells(3, 11) - sht.Cells(m + 2, 11)
sht.Cells(m + 4, 5) = "△α=" & Format(gg, "###.######")
sht.Cells(m + 4, 6) = "△X=" & Format(xx, "###.###")
sht.Cells(m + 4, 7) = "△Y=" & Format(yy, "###.###")
sht.Cells(m + 4, 3) = "∑S=" & Format(S, "###.###")
sht.Cells(m + 4, 9) = "△S=" & Format(Sqr(xx * xx + yy * yy), "###.###")
sht.Cells(m + 4, 10) = "相对精度 1/" & Format(S / Sqr(xx * xx + yy * yy), "######")
For n = 4 To m + 2
sht.Cells(n, 8) = Format(xx / S * sht.Cells(n - 1, 3), "###.####")
sht.Cells(n, 9) = Format(yy / S * sht.Cells(n - 1, 3), "###.####")
Next
For n = 4 To m + 1
sht.Cells(n, 10) = sht.Cells(n - 1, 10) + sht.Cells(n, 6) - sht.Cells(n, 8)
sht.Cells(n, 11) = sht.Cells(n - 1, 11) + sht.Cells(n, 7) - sht.Cells(n, 9)
Next
    Columns("F:K").Select
    Selection.NumberFormatLocal = "0.000_ "
End Sub
Public Function RAD(Nu As Double) As Double
Dim A As Double, B As Double, C As Double, D As Double, E As Double, F As Double, G As Double, p As Double
D = Abs(Nu)
F = Sgn(Nu)
p = 180# / pi
G = p * 60#
A = Int(D * p)
B = Int((D - A / p) * G)
W = B
C = (D - A / p - B / G) * 20.62648062
RAD = (C + A + B / 100) * F
End Function

发表于 2008-6-11 10:18 | 显示全部楼层
太高深了,看不懂。。。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-5-17 17:47 , Processed in 0.166127 second(s), 27 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表