I have been trying to make a triangle using a listbox for quite a while now, I know how to make the top half, but can't make the bottom half. Here are th exact instructions:
Write a program that will ask the user to input a key (letter, number, symbol, etc.) AND a number that will indicate the “size” that will be used to create something like the following display.
Z
ZZ
ZZZ
ZZZZ
ZZZZZ
ZZZZZZ
ZZZZZ
ZZZZ
ZZZ
ZZ
Z
This above example would use the letter “z” and the number (size) that is inputted is 7.
Here's my code:
Public Class Form1
Inherits System.Windows.Forms.Form
Dim number As Integer
Dim num As Integer
Dim X As Integer
Dim output As String
Dim Z As Integer
Dim input As String
+Windows form designer generated code
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ListBox1.Items.Clear()
'To make the top half of the triangle
number = Val(TextBox1.Text)
If number > 100 Then
MsgBox("Please choose a number less than 100")
Else : For X = 1 To number
output += TextBox2.Text
ListBox1.Items.Add(output)
Next X
number = 0
X = 0
output = ""
TextBox1.Text = "0"
End If
Just to let you know:
I'm using a listbox, two textboxes, and a button to make the program work.
I'm using visual basic.net 2003.
Write a program that will ask the user to input a key (letter, number, symbol, etc.) AND a number that will indicate the “size” that will be used to create something like the following display.
Z
ZZ
ZZZ
ZZZZ
ZZZZZ
ZZZZZZ
ZZZZZ
ZZZZ
ZZZ
ZZ
Z
This above example would use the letter “z” and the number (size) that is inputted is 7.
Here's my code:
Public Class Form1
Inherits System.Windows.Forms.Form
Dim number As Integer
Dim num As Integer
Dim X As Integer
Dim output As String
Dim Z As Integer
Dim input As String
+Windows form designer generated code
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ListBox1.Items.Clear()
'To make the top half of the triangle
number = Val(TextBox1.Text)
If number > 100 Then
MsgBox("Please choose a number less than 100")
Else : For X = 1 To number
output += TextBox2.Text
ListBox1.Items.Add(output)
Next X
number = 0
X = 0
output = ""
TextBox1.Text = "0"
End If
Just to let you know:
I'm using a listbox, two textboxes, and a button to make the program work.
I'm using visual basic.net 2003.