请教关于算法优化问题,急!
请教各位大神下面的代码用到一些简单的算法,想请问该如何优化,提升程序的运行速度,谢谢!
'*************************************************
'function :Data Calcuration
' Valu.AveGaik(Valu.MaxGaik, Valu.MinGaik)
' Valu.MaxFure
' Valu.Entdo
' Valu.Result
'parameter :non
'result :true=OK false=NG
'*************************************************
Private Function uflCalc()
Dim i, hed As Integer
Dim RestFg As Boolean
RestFg = True
'--- Base Calcuration
For hed = 1 To 3
'--- 外径平均值计算
Dim AveGaik As Double
AveGaik = 0
For i = 1 To Spec(0).Point
AveGaik = AveGaik + Inpt(hed).Gaik(i)
Next
If AveGaik > 0 Then
Valu.AveGaik(hed) = ufgChgValu(AveGaik / Spec(0).Point)
Else
Valu.AveGaik(hed) = 0
End If
'--- 外径 Data Error Check
If Valu.AveGaik(hed) = 0 Then
RestFg = False
Valu.Result(hed) = "MISS"
End If
'--- 外径最大值,最小值,圆筒度计算
Valu.MaxGaik(hed) = 0
Valu.MinGaik(hed) = 999999
For i = 1 To Spec(0).Point
If Valu.MaxGaik(hed) < Inpt(hed).Gaik(i) Then Valu.MaxGaik(hed) = ufgChgValu(Inpt(hed).Gaik(i))
If Valu.MinGaik(hed) > Inpt(hed).Gaik(i) Then Valu.MinGaik(hed) = ufgChgValu(Inpt(hed).Gaik(i))
Next
Valu.Entdo(hed) = ufgChgValu(Valu.MaxGaik(hed) - Valu.MinGaik(hed))
'--- 偏心最大值,最小值计算
Dim MaxFure, MinFure As Double
MaxFure = 0
MinFure = 999999
For i = 1 To Spec(0).Point
If MaxFure < Inpt(hed).Fure(i) Then MaxFure = Inpt(hed).Fure(i)
If MinFure > Inpt(hed).Fure(i) Then MinFure = Inpt(hed).Fure(i)
Next
Valu.MaxFure(hed) = ufgChgValu(MaxFure - MinFure)
'--- 偏心 Data Error Check
If (MaxFure - MinFure) = 0 Then
RestFg = False
Valu.Result(hed) = "MISS"
End If
Next
'--- All Data Miss Check
If RestFg = False Then
uflCalc = False
Else
uflCalc = True
End If
End Function
'*************************************************
'function :外径差 Calcuration
'parameter :ValuDt() = CalcData
' :dn = DataNum
'result :value
'*************************************************
Private Function uflCalcSa(ValuDt(), dn)
Dim i As Integer
Dim MaxDt, MinDt
MaxDt = 0
MinDt = 999999
For i = 0 To dn - 1
If MaxDt < ValuDt(i) Then MaxDt = ValuDt(i)
If MinDt > ValuDt(i) Then MinDt = ValuDt(i)
Next
uflCalcSa = ufgChgValu(MaxDt - MinDt)
End Function