VBA 用户窗体无法识别功能?

VBA User Form does not recognize if function?

Private Sub ROLparameter_Click()
Line1: RolLow = InputBox("Please enter the lower bound percentage for ROL calculation between 0 and 100 (initially " & RolLow * 100 & "%):")

If Not 0 <= RolLow <= 100 Then GoTo Line1
End If

End Sub

我有用户表单按钮,当我按下它时会进入这个sub。问题是它给出了错误 "end if without if"。当我删除 end if 时,它的工作很奇怪。

如;

当用户输入 80 时,它确实将 RolLow 值识别为“80”。如果不指示它结束子,如果我只使用 "if" 那么它将一直指向第 1 行。不检查值。

此代码在模块中正常工作。

可能是什么问题?

(变量在subs之前定义public)

(我也尝试了 module.variable)

这是您尝试使用的代码 运行: 如果用户输入的值小于 0 或大于 100,则返回 InputBox

Private Sub ROLparameter_Click()

Line1: Rollow = CLng(InputBox("Please enter the lower bound percentage for ROL calculation between 0 and 100 (initially " & Rollow * 100 & "%):"))

If Not ((0 <= Rollow) And (Rollow <= 100)) Then
    GoTo Line1
End If

End Sub