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”中的计数器递增。预先感谢您的任何帮助!