Public Class Form1 Dim n As Integer Dim startH, endH As Double Public Structure pt 'definition site information, including the site name, front two readings, rear view reading twice, elevation difference, modified elevation difference, site distance' Dim HeightDifference As Double Dim ptname As String Dim length As Double Dim frontview1 As Double Dim frontview2 As Double Dim rearview1 As Double Dim rearview2 As Double Dim avgh As Double Dim updateh As Double End Structure of Public p (20) As pt Public Sub readnum () 'data read' Dim s As String If OpenFileDialog1. ShowDialog & lt;> Windows.Forms.DialogResult.Cancel Then s=OpenFileDialog1.FileName End If FileOpen(1, s, OpenMode.Output) WriteLine(1, 3) WriteLine(1, "1", 5, 2, 3, 4, 5) WriteLine(1, "2", 6, 1, 3, 4, 5) WriteLine(1, "3", 5.5, 2, 4, 5, 6) FileClose() FileOpen(1, s, OpenMode.Input) Input(1, n) For i=1 To n Input(1, p(i).ptname) Input(1, p(i).length) Input(1, p(i).frontview1) Input(1, p(i).frontview2) Input(1, p(i).rearview1) Input(1, p(i).rearview2) Next FileClose() End Sub 'Public Sub New(ByVal name As String, ByVal fv1 As Double, ByVal fv2 As Double, ByVal rv1 As Double, ByVal rv2 As Double, ByVal len As Double, ByVal hd As Double) 'End Sub Private Sub HeightComputation(ByRef a As pt) '通过前后视读数来计算站点间的高程差' a.HeightDifference=(a.frontview1 - a.rearview1) + (a.frontview2 - a.rearview2) a.HeightDifference=a.HeightDifference/2.0 End Sub Function TotalHeight(ByVal a() As pt) As Double '计算闭合高程差' Dim fsum As Double For i=1 To n fsum +=a(i).HeightDifference Next Return fsum End Function Function TotalLen(ByVal a() As pt) As Double '计算水准路线长度' Dim Lsum As Double For i=1 To n Lsum +=a(i).length Next Return Lsum End Function Private Sub UpdateHeight(ByRef a() As pt) '进行高差修正' Dim fhPermit, fh, Updatenum As Double fhPermit=10 * Math.Sqrt(TotalLen(a)) fh=TotalHeight(a) - (startH - endH) If Math.Abs(fh)
End the Class