求解一道VB题!
2个回答
展开全部
Private Sub Form_Click()
Dim i As Integer
Dim qw As Integer, bw As Integer
Dim sw As Integer, gw As Integer
For i = 30 To 100
If i ^ 2 >= 1000 And i ^ 2 <= 9999 Then
qw = i ^ 2 \ 1000
bw = (i ^ 2 - qw * 1000) \ 100
sw = (i ^ 2 - qw * 1000 - bw * 100) \ 10
gw = i ^ 2 Mod 10
If qw = bw And sw = gw Then
Print i ^ 2; "= "; i & " ^ 2"
Print "zhe ge shu shi:" & i ^ 2
Exit For
End If
End If
Next
End Sub
'如果你会字符串处理的话会更简洁一些:
Private Sub Form_Click()
Dim i As Integer
For i = 30 To 100
If i ^ 2 >= 1000 And i ^ 2 <= 9999 Then
If Mid(i ^ 2, 1, 1) = Mid(i ^ 2, 2, 1) And _
Mid(i ^ 2, 3, 1) = Mid(i ^ 2, 4, 1) Then
Print i ^ 2; "= "; i & " ^ 2"
Print "zhe ge shu shi:" & i ^ 2
Exit For
End If
End If
Next
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询