主题:帮忙看下这个程序的问题
下面这程序我在vs.net2003里语法没问题,但在运行没效果。谢谢了
Private Sub Button1_Click(…) Handles Button1.Click
Dim flg As Boolean, i%, sum%, n%, t$
For n = 2 To 1000
sum = 1
t = "1" ' 存放各个因子之和表达式
i = 2
Do While i <= n ' 求给定正整数的所有因子
If n Mod i = 0 Then
sum = sum+1
t &= "+" & i
End If
i += 1
Loop
t = t & " = " & sum
Call Prime(sum, flg)
If flg Then
TextBox1.text &= Str(n) & ": " & t & vbCrLf
End If
Next n
End Sub
Private Sub Prime(ByVal s As Integer, flage As Boolean) ' 判断s素数
Dim m%
flage = True
For m = 2 To Sqr(s)
If s Mod m = 0 Then
flage = False
Exit For ' 非素数时,跳出
End If
Next m
End Sub
Private Sub Button1_Click(…) Handles Button1.Click
Dim flg As Boolean, i%, sum%, n%, t$
For n = 2 To 1000
sum = 1
t = "1" ' 存放各个因子之和表达式
i = 2
Do While i <= n ' 求给定正整数的所有因子
If n Mod i = 0 Then
sum = sum+1
t &= "+" & i
End If
i += 1
Loop
t = t & " = " & sum
Call Prime(sum, flg)
If flg Then
TextBox1.text &= Str(n) & ": " & t & vbCrLf
End If
Next n
End Sub
Private Sub Prime(ByVal s As Integer, flage As Boolean) ' 判断s素数
Dim m%
flage = True
For m = 2 To Sqr(s)
If s Mod m = 0 Then
flage = False
Exit For ' 非素数时,跳出
End If
Next m
End Sub