0
 Public Class Form1
Private Sub btnCreateRhombus_Click(sender As Object, e As EventArgs) Handles btnCreateRhombus.Click

    'Declarations
    Dim userInput As Integer
    Dim rowCount As Integer = 1
    Dim spaces As Integer = 0
    Dim stars As String = "****"

    'user imput
    userInput = Convert.ToString(TxtNum1.Text)

    'Calculations

    drawStarSub(userInput, stars, rowCount)

    drawSpaceSub(userInput, stars)

    'Output

End Sub

Sub drawStarSub(userInput As String, stars As String, rowCount As String)

    Dim count As Integer = 1

    While count <= userInput
        stars = stars & vbNewLine & stars

        count = count + 1
    End While

    'Output

    lblResult.Text = Convert.ToString(stars)

End Sub

Sub drawSpaceSub(userInput As Integer, stars As String)

End Sub
End Class

程序需要做的是绘制一个平行四边形 如果用户键入 3 有 3 行,4 有 4 行等......最多 11。我需要为行增量和空间增量做一个子。

我遇到麻烦的地方是让“stars”字符串用“drawStarSub”中的计数器递增。预先感谢您的任何帮助!

4

1 回答 1

0

尝试stars = stars & vbNewLine & stars用这个代替

stars = stars & vbCrLf & stars

这对我有用。就个人而言,我会使用For循环而不是While循环,但这没什么大不了的。

于 2013-11-05T07:40:25.710 回答