gpt4 book ai didi

vba - 为什么我的 for 循环没有加紧?

转载 作者:行者123 更新时间:2023-12-04 21:15:01 24 4
gpt4 key购买 nike

这可能是一个我忽略的简单问题。我有一个 for 循环拒绝按照给定的时间间隔加紧。下面的代码是从更复杂的代码中提取的。我的程序运行了 1 小时,没有任何变化,我设法将其缩小到导致运行时间过长的部分。

我试过在它自己的模块中运行这段代码,同样的问题发生了。我在主要代码块中有其他 for 循环与 step 没有问题就是这个。任何帮助找到我出错的地方将不胜感激。

Sub Test()


Dim h As Long
Dim BiezerP0 As Double
Dim BiezerP1 As Double
Dim BiezerP2 As Double
Dim BiezerP3 As Double
Dim BiezerValue As Double
Dim BiezerStepInterval As Double
Dim BiezerLocation As Double
Dim P0Time As Double

BiezerStepInterval = 0.167


For h = 0 To 1 Step BiezerStepInterval

BiezerP0 = ((1 - h) ^ 3) * P0
BiezerP1 = 3 * ((1 - h) ^ 2) * h * P1
BiezerP2 = 3 * (1 - h) * h * h * P2
BiezerP3 = h * h * h * P3

BiezerValue = BiezerP0 + BiezerP1 + BiezerP2 + BiezerP3

BiezerLocation = h * BiezerSteps
Cells(BiezerLocation + 4, 15) = BiezerValue
Cells(BiezerLocation + 4, 16) = P0Time + (0.02 * BiezerLocation)


Next h
End Sub

我能想到的唯一问题是 0.167 没有直接进入 1。这会影响它吗?

最佳答案

h应该是Double,不长

Dim h As Double

关于vba - 为什么我的 for 循环没有加紧?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48205249/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com