Private Sub Command1_Click()
DEVIDE 355, 113, 1000
End Sub
Sub DEVIDE(ByVal X As Integer, ByVal Y As Integer, Optional ByVal Numdigitsafterdecimal As Integer = 100, Optional ByRef result As String)'x/y取小数点后Numdigitsafterdecimal 位(默认100)
Dim a() As String, temp As Integer, temp2 As Integer, m As Integer
ReDim a(Numdigitsafterdecimal)
result = Int(X / Y) & "."
m = 0
a(m) = X Mod Y
temp = a(m)
Do While m < Numdigitsafterdecimal
temp = temp * 10
temp2 = Int(temp / Y)
temp = temp Mod Y
result = result & Right(temp2, 1)
m = m + 1
a(m) = temp
Loop
result = X & "÷" & Y & "=" & result
Debug.Print result
End Sub