Private?Sub?Command1_Click()
目前成都創(chuàng)新互聯(lián)已為千余家的企業(yè)提供了網(wǎng)站建設(shè)、域名、網(wǎng)絡(luò)空間、網(wǎng)站托管維護(hù)、企業(yè)網(wǎng)站設(shè)計(jì)、尖扎網(wǎng)站維護(hù)等服務(wù),公司將堅(jiān)持客戶導(dǎo)向、應(yīng)用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長,共同發(fā)展。
Dim?m?As?Long
m?=?InputBox("請輸入一個正整數(shù):",?"求一個正整數(shù)的所有因子",?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是函數(shù)的形參,就是參數(shù),在調(diào)用的時(shí)候傳進(jìn)去個啥數(shù)不知道,用它代替
fun(n)的n就是實(shí)參,就是具體傳進(jìn)去的數(shù),傳進(jìn)去后m的數(shù)值就是n了
For k = 1 To Abs(m) / 2,如果這個不是整數(shù)----那需要處理一下,比如用int函數(shù)
fun帶參數(shù)并且作為返回的數(shù)值的時(shí)候fun要帶上()
fun帶參數(shù)并且不作為返回的數(shù)值的時(shí)候fun不要帶上(),fun后面是空格和參數(shù)
沒有參數(shù)的時(shí)候直接寫
Dim i As Integer
Dim a As Integer
Dim sum As Integer
Dim s As String
Dim j As Integer
a = InputBox("請輸入一個數(shù)")
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 "該數(shù)的整數(shù)因子:" s
Print "因數(shù)個數(shù):" j
Print "因數(shù)和:" sum
Private Sub Command1_Click()
Dim n As Integer, i As Integer
n = InputBox("輸入正整數(shù):", , 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