| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 741 人关注过本帖, 2 人收藏
标题:经纬仪测量小软件的问题
只看楼主 加入收藏
lijun337
Rank: 1
等 级:新手上路
帖 子:379
专家分:5
注 册:2006-4-12
结帖率:84.62%
收藏(2)
 问题点数:0 回复次数:3 
经纬仪测量小软件的问题
经纬仪测量小软件的问题:

EXCEL表里有相应的计算CJ和GC的代码如下:

CJ=C3*(D3-F3)*COS(RADIANS((90-(G3+(H3/60)+(I3/3600)))))*COS(RADIANS((90-(G3+(H3/60)+(I3/3600)))))

GC=0.5*C3*(D3-F3)*SIN(RADIANS((2*(90-(G3+(H3/60)+(I3/3600))))))+(A3+B3)-E3

我自己又做了个经纬仪测量工具来计算计算CJ和GC,用起来可能比EXCEL表好用些;

经过实际数值来测试,CJ的数据值计算都正确,但是GC的计算仍然不正确。
查看EXCEL表里的公式:
CJ=C3*(D3-F3)*COS(RADIANS((90-(G3+(H3/60)+(I3/3600)))))*COS(RADIANS((90-(G3+(H3/60)+(I3/3600)))))

GC=0.5*C3*(D3-F3)*SIN(RADIANS((2*(90-(G3+(H3/60)+(I3/3600))))))+(A3+B3)-E3



和自己编写的VB代码里计算代码(代码如下:)进行比较:实在找不到语法错在哪?
Dim a, aa, b, bb, c, cc, d, dd, f, ff, g, l, gg, m, mm, ss, zz, xx, cj As Long
Dim zh, cz, yg, spd, gaocha, gc, ggcc, gach, ssppdd As Long
zh = Val(Text1.Text)
cz = Val(Text2.Text)
yg = Val(Text3.Text)


dd = Val(Text7.Text)
ff = Val(Text8.Text)
mm = Val(Text9.Text)
ss = Val(Text4.Text)
zz = Val(Text5.Text)
xx = Val(Text6.Text)
l = ss - xx

dd = dd / 180
ff = ff / 60 / 180
mm = mm / 3600 / 180
c = dd + mm + ff

g = c * 3.1415926


spd = 100 * l * Sin(g) * Sin(g)

gc = cz + 100 * l * Sin(g) * Cos(g) + yg - zz

If Val(spd * 10) > Int(Val(spd * 10)) + 0.4 Then
Text11.Text = Int(spd * 10 + 1) / 10
Else: Text11.Text = Int(Val(spd * 10)) / 10
End If


If Val(gc * 10) > Int(Val(gc * 10)) + 0.4 Then
Text12.Text = Int(gc * 10 + 1) / 10
Else: Text12.Text = Int(Val(gc * 10)) / 10
End If

End Sub

只好列上全部代码如下,供高手参考:

Option Explicit
Public appdisk As String
Private conn As ADODB.Connection
Private Rst As New ADODB.Recordset

Private Sub Command2_Click()
End
End Sub




Private Sub Command1_Click()

Dim sXLSPath As String

 Dim s As String
    Dim i As Integer
    Dim myexcel As New Excel.Application
    Dim mybook As New Excel.Workbook
    Dim mysheet As New Excel.Worksheet
    Set mybook = myexcel.Workbooks.Add '添加一个新的BOOK
    Set mysheet = mybook.Worksheets.Add '添加一个新的SHEET
    myexcel.Visible = True
    myexcel.UserControl = True
'    myexcel.Visible = False
If (Rst.State = adStateOpen) Then
        Rst.Close
    End If
    Rst.CursorLocation = adUseClient
    Rst.Open "Select * From cl3", conn, adOpenKeyset, adLockPessimistic
    Rst.AddNew
    Rst.Fields("zh").Value = Text1.Text
    Rst.Fields("cz").Value = Text2.Text
    Rst.Fields("yg").Value = Text3.Text
    Rst.Fields("dd").Value = Text4.Text
    Rst.Fields("ff").Value = Text5.Text
    Rst.Fields("mm").Value = Text6.Text
    Rst.Fields("ss").Value = Text7.Text
    Rst.Fields("zz").Value = Text8.Text
    Rst.Fields("xx").Value = Text9.Text
    Rst.Fields("spd").Value = Text11.Text
    Rst.Fields("gc").Value = Text12.Text
    Rst.Update
    MsgBox ("保存成功!")
Text1.SetFocus
    Text1.Text = ""
    Text2.Text = ""
    Text3.Text = ""
    Text4.Text = ""
    Text5.Text = ""
    Text6.Text = ""
    Text7.Text = ""
    Text8.Text = ""
    Text9.Text = ""
    Text11.Text = ""
    Text12.Text = ""

For i = 1 To Rst.Fields.Count
        mysheet.Cells(1, i).Value = Rst.Fields(i - 1).Name
    Next i
    mysheet.Cells(2, 1).CopyFromRecordset Rst
       mybook.SaveAs (1)
   
    Set mysheet = Nothing
    Set mybook = Nothing
    Set myexcel = Nothing
    MsgBox "转换数据成功!"
End Sub





Private Sub Command3_Click()
Dim a, aa, b, bb, c, cc, d, dd, f, ff, g, l, gg, m, mm, ss, zz, xx, cj As Long
Dim zh, cz, yg, spd, gaocha, gc, ggcc, gach, ssppdd As Long
zh = Val(Text1.Text)
cz = Val(Text2.Text)
yg = Val(Text3.Text)


dd = Val(Text7.Text)
ff = Val(Text8.Text)
mm = Val(Text9.Text)
ss = Val(Text4.Text)
zz = Val(Text5.Text)
xx = Val(Text6.Text)
l = ss - xx

dd = dd / 180
ff = ff / 60 / 180
mm = mm / 3600 / 180
c = dd + mm + ff

g = c * 3.1415926


spd = 100 * l * Sin(g) * Sin(g)

gc = cz + 100 * l * Sin(g) * Cos(g) + yg - zz

If Val(spd * 10) > Int(Val(spd * 10)) + 0.4 Then
Text11.Text = Int(spd * 10 + 1) / 10
Else: Text11.Text = Int(Val(spd * 10)) / 10
End If


If Val(gc * 10) > Int(Val(gc * 10)) + 0.4 Then
Text12.Text = Int(gc * 10 + 1) / 10
Else: Text12.Text = Int(Val(gc * 10)) / 10
End If





Command1.SetFocus
End Sub

Private Sub Form_Load()
Dim ConString As String
    ConString = "Provider=Microsoft.Jet.OleDb.4.0;Persist Security Info = False;" _
               & "Data Source =" & App.Path & "\cl.mdb"
   
    Set conn = CreateObject("ADODB.Connection")
    With conn
        .ConnectionString = ConString
        .Open
    End With
   
    Rst.CursorLocation = adUseClient
    Rst.Open "Select * From cl3", conn, adOpenKeyset, adLockPessimistic, adCmdText
   
   
    Text1.Text = ""
    Text2.Text = ""
    Text3.Text = ""
    Text4.Text = ""
    Text5.Text = ""
    Text6.Text = ""
    Text7.Text = ""
    Text8.Text = ""
    Text9.Text = ""
    Text11.Text = ""
    Text12.Text = ""
   


End Sub

Private Sub Text9_Change()
Dim a, aa, b, bb, c, cc, d, dd, f, ff, g, l, gg, m, mm, ss, zz, xx, cj As Long
Dim zh, cz, yg, spd, gaocha, gc, ggcc, gach, ssppdd As Long
zh = Val(Text1.Text)
cz = Val(Text2.Text)
yg = Val(Text3.Text)


dd = Val(Text7.Text)
ff = Val(Text8.Text)
mm = Val(Text9.Text)
ss = Val(Text4.Text)
zz = Val(Text5.Text)
xx = Val(Text6.Text)
l = ss - xx

dd = dd / 180
ff = ff / 60 / 180
mm = mm / 3600 / 180
c = dd + mm + ff

g = c * 3.1415926


spd = 100 * l * Sin(g) * Sin(g)
gaocha = spd * Sin(g) * Cos(g)
gc = cz + gaocha + yg - zz

If Val(spd * 10) > Int(Val(spd * 10)) + 0.4 Then
Text11.Text = Int(spd * 10 + 1) / 10
Else: Text11.Text = Int(Val(spd * 10)) / 10
End If


If Val(gc * 10) > Int(Val(gc * 10)) + 0.4 Then
Text12.Text = Int(gc * 10 + 1) / 10
Else: Text12.Text = Int(Val(gc * 10)) / 10
End If


End Sub
搜索更多相关主题的帖子: 软件 经纬仪 
2010-03-31 12:53
lijun337
Rank: 1
等 级:新手上路
帖 子:379
专家分:5
注 册:2006-4-12
收藏
得分:0 
我把字符"long"改为"single",

gaocha = 100 *l* Sin(g) * Cos(g)


其余未动!

再次验算,结果正确!

谢谢!

2010-03-31 13:23
zengsijun
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2010-4-1
收藏
得分:0 
学习一下,谢谢楼主!!
2010-04-01 12:30
liuzhixue1
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2010-3-30
收藏
得分:0 
新手 看不明白
2010-04-02 16:14
快速回复:经纬仪测量小软件的问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018781 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved