Hi all,
I'm not that great with columns, as you can see by this picture:
Attachment 99159
Also, I need help getting the Price column (right column) to format to currency once it hits the list.
Any help would be greatly appreciated. My code is below.
Public Class Form1
Dim x As Integer
Dim productName(10) As String
Dim productNumber(10) As String
Dim productPrice(10) As Double
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
x += 1
productName(x) = TextBox1.Text
productNumber(x) = TextBox2.Text
productPrice(x) = TextBox3.Text
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox1.Focus()
If x = 10 Then
Button1.Enabled = False
TextBox1.Enabled = False
TextBox2.Enabled = False
TextBox3.Enabled = False
ListBox1.Items.Add("Array full")
End If
End Sub
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
Dim y As Integer
Dim template As String = "{0,-30} {1,-30} {2,10}" 'This is a column template - "Lets create a string, and edit it, so that we have a 10 character column, left justified, then a couple spaces later, a 3 digit column
ListBox1.Items.Clear()
ListBox1.Items.Add(String.Format(template, "Product Name", "Product Number", "Price")) 'This is the header for each column
ListBox1.Items.Add(String.Format(template, "------------", "--------------", "-----")) 'This creates the underline for the headers
For y = 1 To x
ListBox1.Items.Add(String.Format(template, productName(y), productNumber(y), productPrice(y))) 'This calls on the template variable that was set up
Next
End Sub
End Class
I'm not that great with columns, as you can see by this picture:
Attachment 99159
Also, I need help getting the Price column (right column) to format to currency once it hits the list.
Any help would be greatly appreciated. My code is below.
Public Class Form1
Dim x As Integer
Dim productName(10) As String
Dim productNumber(10) As String
Dim productPrice(10) As Double
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
x += 1
productName(x) = TextBox1.Text
productNumber(x) = TextBox2.Text
productPrice(x) = TextBox3.Text
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox1.Focus()
If x = 10 Then
Button1.Enabled = False
TextBox1.Enabled = False
TextBox2.Enabled = False
TextBox3.Enabled = False
ListBox1.Items.Add("Array full")
End If
End Sub
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
Dim y As Integer
Dim template As String = "{0,-30} {1,-30} {2,10}" 'This is a column template - "Lets create a string, and edit it, so that we have a 10 character column, left justified, then a couple spaces later, a 3 digit column
ListBox1.Items.Clear()
ListBox1.Items.Add(String.Format(template, "Product Name", "Product Number", "Price")) 'This is the header for each column
ListBox1.Items.Add(String.Format(template, "------------", "--------------", "-----")) 'This creates the underline for the headers
For y = 1 To x
ListBox1.Items.Add(String.Format(template, productName(y), productNumber(y), productPrice(y))) 'This calls on the template variable that was set up
Next
End Sub
End Class