VB 编写函数fun,函数的功能是:求1-1000内能同时被m,n整除的数的总和并显示.
问题描述:
VB 编写函数fun,函数的功能是:求1-1000内能同时被m,n整除的数的总和并显示.
答
Function s(ByVal a As Integer,ByVal b As Integer) As Integer
Dim i As Integer
For i = 1 To 1000
If i Mod a = 0 And i Mod b = 0 Then
s = s + i
End If
Next
End Function