Private Sub Command1_Click()
Text1.Text = ""
For i = 10 To 200
For j = 2 To Sqr(i)
If i Mod j = 0 Then Exit For
Next
If j > Sqr(i) Then
Text1.Text = Text1.Text & i & " "
k = k + 1
If k Mod 5 = 0 Then Text1.Text = Text1.Text & vbCrLf
End If
Next
Text2.Text = "10-200之间所有的素数个数=" & k
End Sub
Private Sub Command2_Click()
Text1.Text = ""
For i = 10 To 200
If i < 100 And i Mod 11 = 0 Or i >= 100 And i \ 100 = i Mod 10 Then
Text1.Text = Text1.Text & i & " "
k = k + 1
If k Mod 5 = 0 Then Text1.Text = Text1.Text & vbCrLf
End If
Next
Text2.Text = "10-200之间所有的回文数个数=" & k
End Sub
编辑本段用visual basic6.0 计算回文数
for i = 100 to 99999 '这里从100开始 后面可以随便填,我这里填99999 表示所有3位数到五位数之间的回文数 if StrReverse(i)=i then print i '用StrReverse函数 判断倒序后的数和原来数是否相同,如果相同者表示此数为回文数 next