My instructions for this project are: Create a program that builds a triangle in a list box by using nested loops. The program should accept a number from the user that says how many lines the triangle should have. The first line in the list box would have one character, the second line two characters and so on until the triangle is complete.
I have tried and it just wont work, I dont know where to go with it from here. Here is what I have so far:
CODE
Public Class frmTriangle
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents cmdBuild As System.Windows.Forms.Button
Friend WithEvents cmdExit As System.Windows.Forms.Button
Friend WithEvents lstTri As System.Windows.Forms.ListBox
Friend WithEvents txtSize As System.Windows.Forms.TextBox
Friend WithEvents lblSize As System.Windows.Forms.Label
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.lstTri = New System.Windows.Forms.ListBox
Me.cmdBuild = New System.Windows.Forms.Button
Me.cmdExit = New System.Windows.Forms.Button
Me.txtSize = New System.Windows.Forms.TextBox
Me.lblSize = New System.Windows.Forms.Label
Me.SuspendLayout()
'
'lstTri
'
Me.lstTri.Location = New System.Drawing.Point(16, 8)
Me.lstTri.Name = "lstTri"
Me.lstTri.Size = New System.Drawing.Size(184, 186)
Me.lstTri.TabIndex = 0
'
'cmdBuild
'
Me.cmdBuild.Location = New System.Drawing.Point(208, 176)
Me.cmdBuild.Name = "cmdBuild"
Me.cmdBuild.TabIndex = 1
Me.cmdBuild.Text = "Build"
'
'cmdExit
'
Me.cmdExit.Location = New System.Drawing.Point(208, 216)
Me.cmdExit.Name = "cmdExit"
Me.cmdExit.TabIndex = 2
Me.cmdExit.Text = "Exit"
'
'txtSize
'
Me.txtSize.Location = New System.Drawing.Point(216, 136)
Me.txtSize.Name = "txtSize"
Me.txtSize.Size = New System.Drawing.Size(48, 20)
Me.txtSize.TabIndex = 3
Me.txtSize.Text = ""
'
'lblSize
'
Me.lblSize.AutoSize = True
Me.lblSize.Location = New System.Drawing.Point(224, 104)
Me.lblSize.Name = "lblSize"
Me.lblSize.Size = New System.Drawing.Size(26, 16)
Me.lblSize.TabIndex = 4
Me.lblSize.Text = "Size"
'
'frmTriangle
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 266)
Me.Controls.Add(Me.lblSize)
Me.Controls.Add(Me.txtSize)
Me.Controls.Add(Me.cmdExit)
Me.Controls.Add(Me.cmdBuild)
Me.Controls.Add(Me.lstTri)
Me.Name = "frmTriangle"
Me.Text = "Triangle List"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub cmdExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdExit.Click
End
End Sub
Private Sub lstTri_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstTri.SelectedIndexChanged
lstSize.Items.Clear()
lstSize.Items.Add("*")
Do While intCounter <= intRepeat
lstbox.Items.Add(strTemp)
intCounter = intCounter + 1
strTemp = strTemp + "* "
Loop
End Sub
Private Sub cmdBuild_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdBuild.Click
'Declair loop
Dim intA As Integer
'Declare a working string variable
Dim strOutput As String
'Build a character pattern
For intA = 1 To 1 Step 1
strOutput += "*"
Next
End Sub
Private Sub txtSize_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtSize.TextChanged
'Number is short and integer
Dim txtSize As Integer
intSize = Val(txtSize.text)
End Sub
End Class
ANY HELP WOULD BE GREATLY APPRICIATED:)