判断一个数是否是自守数(同构数)
菜鸟上路,求助各位大神。我想问一下,我写的这一个编程哪里不对。我把我觉得不大对的地方标注了一下。我试着运行了下,但是平方后的数超过4位就会出现错误,比如25输进去是对的,但是9376就不对了。
Private Sub Command1_Click()
Dim x As Long
x = Val(Text1.Text)
If verify(x) Then
Picture1.Print Text1.Text
Else
MsgBox Str(x) & "不是自守数。", vbInformation
End If
End Sub
Private Function verify(x As Long) As Boolean
Dim y As Long, s As Integer, z As String
verify = False
y = x * x
s = y Mod 100
If x = Val(Right(CStr(y), s)) Then
verify = True
End If
End Function
Private Sub Command2_Click()
Text1 = ""
End Sub
Private Sub Command3_Click()
End
End Sub
请大家帮帮忙啦,万分感谢!!