所以我试图让两个整数N
和D
分先后,直到余数是大于或等于0.000001
需要分割的数量。我不知道我错在哪里。划分和计算划分数连续
数据类型是否用于N
,D
和Z
错误,还是别的?
Option Explicit
Sub Ediv()
Dim N As Integer
Dim D As Integer
Dim Z As Long
Dim intCount As Integer
With Sheets("Functions")
N = Cells(16, "B").Value
D = Cells(16, "C").Value
If D < 1 Then
MsgBox "Divisor is less than 1 enter value greater than 1"
Exit Sub
Else
End If
intCount = 0
Do While Z >= 0.000001
Z = N/D
intCount = intCount + 1
N = Z
Loop
Cells(16, "D").Value = intCount
End With
End Sub
试一下'Dim N As Double,D As Double,Z as Double'。整数本质上不能包含混合数的小数部分;只有1,2,3等。 – Jeeped
@Jeeped谢谢,但仍然没有改变。 –
提供B16:C16中的一些示例以及您的期望。 – Jeeped