代码有什么问题? [英] what wrong with the code?
本文介绍了代码有什么问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Dim i, j As Integer
TextBox1.TextAlign = HorizontalAlignment.Center
Do While i < 1
i = i - 1
j = 1
Do While j < i - 1
TextBox1.Text = TextBox1.Text & " *"
Loop
TextBox1.Text = TextBox1.Text & vbCrLf
Loop
End Sub
需要出局:倒金字塔
S *****
S ****
SS ***
SS **
SS *
帮助tnx:)
need out put: inverted pyramid
S*****
S****
SS***
SS**
SS*
help tnx :)
推荐答案
在我看来,整数i应该增加而不是减少,你需要在开始时为它设置一个值。 (如果你的输出看起来像你说的那样)
嗯。不,它应该减少但是While条件关闭,我认为
It seems to me that the integer i should increase instead of decrease, and you would need to set a value for it at the start. (if you the output to look like what you said)
Uhm. No, it should decrease but the While condition was off, I think
Dim i, j As Integer
TextBox1.TextAlign = HorizontalAlignment.Center
'' clear the TextBox1.Text before you fill it with the *'s
TextBox1.Text = ""
'' Set the amount of *'s you want the first line to contain
i = 7
Do While i > 1
j = 1
Do While j < i
TextBox1.Text = TextBox1.Text & "*"
j = j + 1
Loop
TextBox1.Text = TextBox1.Text & vbCrLf
'' I would decrease i here, and not before the j-loop so that i indicates the amount of *'s in each line correctly
i = i - 1
Loop
End Sub
我会这样尝试,希望这有帮助!
PS不要忘记TextBox1.Multiline = True。我知道我也会l /
,如果出现问题,请告诉我们你得到的错误信息/什么。
另一个编辑:如果你想要第一行有5 *'s,你需要将i设置为5,而不是像我一样设置
I''d try it like that, hope this helped!
P.S. Don''t forget the TextBox1.Multiline = True . I know I would lol
also, if something still goes wrong please tell us what error message you''re getting/whatever.
Another if you want the first line to have 5 *''s, you will want to set i to 5, not 7 as I did
你需要从一个初始i开始值 - 在这种情况下 i = 6
。
You need to start with an initial i value - in this case i=6
.
这篇关于代码有什么问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文