0

我有一个 If, Elseif, Else 语句。如果满足第一个 If,我想插入径流和渗透的计算值。但是,如果不满足第一个 IF 条件,则径流和渗流将始终被指定为 0。我在下面粘贴了我的代码。我遇到的问题是,如果我在第一个 IF 语句之后设置 percolation 和 runoff=0,我的 print sub 将始终打印 0,而不是计算值。如果不满足第一个 IF 条件,如何将径流和渗透分配为​​常量?我知道我可以在每个后续条件中分配 runoff=0, percolation=0,但我正在尝试减少代码的体积。

 Do
         If (fc - WC(j - 1) + RefET(i)) <= Precip(i) Then
                WC(j) = fc
                WCinit(j) = WC(j)
                Runoff(j - 1) = (Precip(i) - (fc - WC(j - 1) + RefET(i))) * 0.5
                Percolation(j - 1) = (Precip(i) - (fc - WC(j - 1) + RefET(i))) * 0.5
'    Runoff(j - 1) = 0 <-If I assign these here, it "overrides" the value I calculated on the previous line. I want to reduce the bulkiness of my code by assigning these values if the first IF condition is not met
'    Percolation(j - 1) = 0
          ElseIf (WC(j - 1) + Precip(i) - RefET(i)) > pwp Then
                 WC(j) = WC(j - 1) + Precip(i) - RefET(i)
                 WCinit(j) = WC(j)
                 Runoff(j - 1) = 0
                 Percolation(j - 1) = 0
        Else
                WC(j) = pwp
                WCinit(j) = WC(j)
                Runoff(j - 1) = 0
                Percolation(j - 1) = 0
        End If
                j = j + 1
                i = i + 1
                Loop While j < 14
4

1 回答 1

1

或者当你标注它们时。暗淡渗透为 int = 0

于 2013-03-21T15:08:56.883 回答