vb for循环数字
Dima,b,c,d,eAsIntegerDimAbcdAsLongDimdcbaAsLongFora=1To9Forb=1To9Forc=1To9Ford=1To9Fo...
Dim a, b, c, d, e As Integer
Dim Abcd As Long
Dim dcba As Long
For a = 1 To 9
For b = 1 To 9
For c = 1 To 9
For d = 1 To 9
For e = 1 To 9
Abcd = a * 1000 + b * 100 + c * 10 + d
dcba = d * 1000 + c * 100 + b * 10 + a
If Abcd * e = dcab Then
Text1.Text = a
Text2.Text = b
Text3.Text = c
Text4.Text = d
End If
Next e, d, c, b, a
这个到底是哪里错咯啊,为什么不显示啊?
题目要求:目的:ABCD*E=DCBA(A,D不是0),而且A,B,C,D,E都是个位整数且大于0。请不择手段,求出A,B,C,D,E的所有结果。 展开
Dim Abcd As Long
Dim dcba As Long
For a = 1 To 9
For b = 1 To 9
For c = 1 To 9
For d = 1 To 9
For e = 1 To 9
Abcd = a * 1000 + b * 100 + c * 10 + d
dcba = d * 1000 + c * 100 + b * 10 + a
If Abcd * e = dcab Then
Text1.Text = a
Text2.Text = b
Text3.Text = c
Text4.Text = d
End If
Next e, d, c, b, a
这个到底是哪里错咯啊,为什么不显示啊?
题目要求:目的:ABCD*E=DCBA(A,D不是0),而且A,B,C,D,E都是个位整数且大于0。请不择手段,求出A,B,C,D,E的所有结果。 展开
2个回答
展开全部
Private Sub Command1_Click()
Dim a&, b&, c&, d&, e& ' As long
Dim Abcd As Long
Dim dcba As Long
For a = 1 To 9
For b = 1 To 9
For c = 1 To 9
For d = 1 To 9
For e = 1 To 9
Abcd = a * 1000 + b * 100 + c * 10 + d
dcba = d * 1000 + c * 100 + b * 10 + a
If Abcd * e = dcba Then'是dcba,你马虎了
Print a&; b&; c&; d&; e'如果用你的那种写法只会将最后的值赋值给文本框
End If
Next e, d, c, b, a
End Sub
你可以试试
Dim a&, b&, c&, d&, e& ' As long
Dim Abcd As Long
Dim dcba As Long
For a = 1 To 9
For b = 1 To 9
For c = 1 To 9
For d = 1 To 9
For e = 1 To 9
Abcd = a * 1000 + b * 100 + c * 10 + d
dcba = d * 1000 + c * 100 + b * 10 + a
If Abcd * e = dcba Then'是dcba,你马虎了
Print a&; b&; c&; d&; e'如果用你的那种写法只会将最后的值赋值给文本框
End If
Next e, d, c, b, a
End Sub
你可以试试
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Option Explicit
Private Sub Command1_Click()
Dim a&, b&, c&, d&, e& ' As long
Dim Abcd As Long
Dim dcba As Long
For a = 1 To 9
For b = 0 To 9
For c = 0 To 9
For d = 1 To 9
For e = 1 To 9
Abcd = a * 1000 + b * 100 + c * 10 + d
dcba = d * 1000 + c * 100 + b * 10 + a
If Abcd * e = dcba Then
Text1.Text = Text1.Text & vbCrLf & Abcd & "*" & e
End If
Next e, d, c, b, a
End Sub
Private Sub Command1_Click()
Dim a&, b&, c&, d&, e& ' As long
Dim Abcd As Long
Dim dcba As Long
For a = 1 To 9
For b = 0 To 9
For c = 0 To 9
For d = 1 To 9
For e = 1 To 9
Abcd = a * 1000 + b * 100 + c * 10 + d
dcba = d * 1000 + c * 100 + b * 10 + a
If Abcd * e = dcba Then
Text1.Text = Text1.Text & vbCrLf & Abcd & "*" & e
End If
Next e, d, c, b, a
End Sub
追问
不对啊 ~
追答
怎么不对?
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询