2016-10-04 29 views
0

我在下面有一個簡單的案例陳述,應該在Case -1 To -10案件中評估-1,它正在跳過它。我最初以爲這個bug來源於Select Case Val(firstOptionLegArray(UBound(firstOptionLegArray))) + Val(secondOptionLegArray(UBound(secondOptionLegArray))),因爲它並沒有對我的預期進行評估(在這個特定情況下,它應該是+1 + -2)。選擇案件號碼範圍未註冊

Ran a Debug.Print line並且事實上按照預期評估爲-1。我錯過了什麼?

Debug.Print Val(firstOptionLegArray(UBound(firstOptionLegArray))) + Val(secondOptionLegArray(UBound(secondOptionLegArray))) 

       Select Case Val(firstOptionLegArray(UBound(firstOptionLegArray))) + Val(secondOptionLegArray(UBound(secondOptionLegArray))) 

        Case 0 
        'No ratio 

         assemblyString = "LIVE " & GetOptionCodes(Mid(tradeLegStructureArray(0), 8, 2)) & " " & TranslateExpirationDate(firstOptionLegArray(3)) & " " & Format(firstOptionLegArray(5), "##0.00") & "/" & _ 
         Format(secondOptionLegArray(5), "##0.00") & " Fence" 

        Case -1 To -10 
        'Ratio 

         assemblyString = "LIVE " & GetOptionCodes(Mid(tradeLegStructureArray(0), 8, 2)) & " " & TranslateExpirationDate(firstOptionLegArray(3)) & " " & Format(firstOptionLegArray(5), "##0.00") & "/" & _ 
         Format(secondOptionLegArray(5), "##0.00") & " " & Abs(firstOptionLegArray(UBound(firstOptionLegArray))) & "x" & Abs(secondOptionLegArray(UBound(secondOptionLegArray))) & " Fence" 

       End Select 
+3

你必須先寫低數。所以:'案件-10至-1' – gizlmo

回答

3

的值必須按升序排列的情況line

Case -10 To -1