Private Sub Command1_Click()
MsgBox numsp(20038, 2500, 2510)
End Sub
Public Function numsp(Num As Long, lstart As Long, lend As Long) As String
Dim lm As Long
Dim lb As Long
Dim lmm As Long
Dim lmb As Long
Dim strTemp As String
If IsNumeric(Num) = False Then Exit Function
lm = Num Mod lstart
lb = Fix(Num / lstart)
If lm = 0 Then
strTemp = lstart & "*" & lb
ElseIf lm > 0 Then
lmm = lm Mod (lend - lstart)
lmb = Fix(lm / (lend - lstart))
If lmm = 0 Then
If lmb > lb Then
strTemp = lstart & "*" & lb & "+" & lm
Else
strTemp = lend & "*" & lmb
strTemp = strTemp & "+" & lstart & "*" & (lb - lmb)
End If
Else
If lmb < lb Then
strTemp = lend & "*" & lmb
strTemp = strTemp & "+" & (lstart + lmm)
strTemp = strTemp & "+" & lstart & "*" & (lb - lmb - 1)
ElseIf lmb = lb Then
strTemp = lstart & "*" & lb & "+" & lm
End If
End If
End If
numsp = strTemp
End Function
这个答案 还行吧~
[此贴子已经被作者于2007-9-24 16:03:14编辑过]