我写了一个VBA代码来input数据,但它不适用于小数

所以这是代码,只适用于整数

Dim CoupRate As Double Do CoupRate = InputBox("enter coupon rate in percent without % sign. It must be between 0.00% and 25.00%") If CoupRate < 0 Or CoupRate > 25 Then MsgBox ("CoupRate must be between 0% and 25%") Else Exit Do End If Loop 

请使用逗号,而不是点.

我也能够在输出中得到小数。 你能不能更具体一些?

  CoupRate = InputBox("enter coupon rate in percent without % sign. It must be between 0.00% and 25.00%") If CoupRate < 0 Or CoupRate > 25 Then MsgBox ("CoupRate must be between 0% and 25%") Else 'Exit Do MsgBox CoupRate & "%" End If