Sub main()
Dim app As Object
Set app = CreateObject("pcdlrn.application")
Dim part As Object
Set part = app.ActivePartProgram
Dim cmds As Object
Set cmds = part.Commands
Dim cmd As Object
Dim theoTZ As Double
Dim arr(10000) As Single
Dim i As Integer
i = 1
For Each cmd In cmds
If cmd.IsMeasuredFeature Or cmd.IsDCCFeature Then
theoTZ = cmd.GetText(THEO_Z, 0)
arr(i) = theoTZ
End If
i = i + 1
Next cmd
Set cmd = cmds.Add(ASSIGNMENT, True)
abc = cmd.PutText("MAXTZ1", DEST_EXPR, 0)
abc = cmd.PutText(max(arr), SRC_EXPR, 0)
End Sub
Function max(a() As Single) As Single
Dim bb As Integer, pp As Single
pp = a(1)
For bb = 2 To UBound(a)
If pp < a(bb) Then pp = a(bb)
Next bb
max = pp
End Function
--------------------------------------------------------------
以上代码中,有谁能帮我把数组长度改为变量,也就是说改为当前程序下手动和自动特征个数的总和,谢谢!