Private Sub Command1_Click()
目前成都创新互联已为千余家的企业提供了网站建设、域名、网络空间、网站托管维护、企业网站设计、尖扎网站维护等服务,公司将坚持客户导向、应用为本的策略,正道将秉承"和谐、参与、激情"的文化,与客户和合作伙伴齐心协力一起成长,共同发展。
Dim m As Long
m = InputBox("请输入一个正整数:", "求一个正整数的所有因子", Int(Rnd * 1000000 + 1))
Print m "的因子有:1 ";
If m 1 Then
For i = 2 To m
If m Mod i = 0 Then Print i;
Next i
End If
End Sub
m是函数的形参,就是参数,在调用的时候传进去个啥数不知道,用它代替
fun(n)的n就是实参,就是具体传进去的数,传进去后m的数值就是n了
For k = 1 To Abs(m) / 2,如果这个不是整数----那需要处理一下,比如用int函数
fun带参数并且作为返回的数值的时候fun要带上()
fun带参数并且不作为返回的数值的时候fun不要带上(),fun后面是空格和参数
没有参数的时候直接写
Dim i As Integer
Dim a As Integer
Dim sum As Integer
Dim s As String
Dim j As Integer
a = InputBox("请输入一个数")
For i = 1 To a
If a Mod i = 0 Then
If s "" Then s = s ","
s = s i
sum = sum + i
j = j + 1
End If
Next i
Print "该数的整数因子:" s
Print "因数个数:" j
Print "因数和:" sum
Private Sub Command1_Click()
Dim n As Integer, i As Integer
n = InputBox("输入正整数:", , 0)
If n 0 Then
Text1.Text = Empty
For i = 1 To n - 1
If n Mod i = 0 Then
Text1.Text = Text1.Text i ","
End If
Next
Text1.Text = Left(Text1.Text, Len(Text1.Text) - 1)
End If
End Sub