所以我試圖讓兩個整數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