Public Function Diamond(ByVal num As Integer) As String Dim i, j As Integer, st As String = If (num Mod 2 = 0) Then Return End If '输出上三角形 For i = 1 To (num + 1) \ 2 For j = 1 To (num + 1) / 2 - i st = st & Next For j = 1 To 2 * i - 1 st = st & * Next st = st & vbCrLf Next '输出下三角形 For i = 1 To (num - 1) \ 2 For j = 1 To i st = st & Next For j = 1 To num - 2 * i st = st & * Next st = st & vbCrLf Next Return st End Function Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click Dim str As String = str = Diamond(7) TextBox6.Text = str End Sub
我看不倒问题哎。