我有这个函数,它根据可用库存计算某些产品的建议价格,现在它的作用并不重要,但它以某种方式运行,我的程序在没有它的情况下运行得像 x10 更快,我真的很困惑,我不确定为什么它很慢
Dim MinPrice As Double
Dim VAT = 1.1899999999999999
Dim margin1
Dim potherrule1 As String
Dim margin2
Dim potherrule2 As String
Dim margin3
Dim potherrule3 As String
Dim defaultmargin
If SupplierMargin IsNot Nothing Then
margin1 = SupplierMargin(0)
potherrule1 = SupplierPother(0)
margin2 = SupplierMargin(1)
potherrule2 = SupplierPother(1)
margin3 = SupplierMargin(2)
potherrule3 = SupplierPother(2)
defaultmargin = SupplierMargin(3)
End If
If IsDBNull(CurrentPother) Or (potherrule1 = "x" And potherrule2 = "x" And potherrule3 = "x") Then
MinPrice = Math.Round((oprice / (1 - defaultmargin)) * VAT, 2)
Return MinPrice
End If
If Not IsDBNull(CurrentPother) Then
If potherrule1 <> "x" Then
Dim v1 As Integer
Dim v2 As Integer
Dim rule As String = potherrule1
Dim parts() As String = rule.Split(New String() {" bis "}, StringSplitOptions.None)
v1 = Integer.Parse(parts(0))
v2 = Integer.Parse(parts(1))
If CurrentPother >= v1 And CurrentPother <= v2 Then
MinPrice = Math.Round((oprice / (1 - margin1)) * VAT, 2)
End If
Return MinPrice
ElseIf potherrule2 <> "x" Then
Dim v1 As Integer
Dim v2 As Integer
Dim rule As String = potherrule2
Dim parts() As String = rule.Split(New String() {" bis "}, StringSplitOptions.None)
v1 = Integer.Parse(parts(0))
v2 = Integer.Parse(parts(1))
If CurrentPother >= v1 And CurrentPother <= v2 Then
MinPrice = Math.Round((oprice / (1 - margin2)) * VAT, 2)
Return MinPrice
End If
ElseIf potherrule2 <> "x" Then
Dim v1 As Integer
Dim v2 As Integer
Dim rule As String = potherrule3
Dim parts() As String = rule.Split(New String() {" bis "}, StringSplitOptions.None)
v1 = Integer.Parse(parts(0))
v2 = Integer.Parse(parts(1))
If CurrentPother >= v1 And CurrentPother <= v2 Then
MinPrice = Math.Round((oprice / (1 - margin3)) * VAT, 2)
Return MinPrice
End If
Else
MinimumPriceWhenPother4IsDBnull(SupplierMargin, oprice)
End If
End If
您能否建议一些可以使此功能更快的改进?