Click here to Skip to main content
15,896,314 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello,
I am trying to figure out how to use the data that I inputted from my "listbox" on Form1 to fill the "histogram" on Form2.

I finally figured out how to get the data into the listbox. See code below:

Public Class Form1
Friend myArray(5) As StringAlignment
Friend index As Integer = 0

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Try
myArray(index) = Me.TextBox1.Text
index += 1
Me.ListBox1.Items.Add(TextBox1.Text)
Me.TextBox1.Clear()
Me.TextBox1.Focus()
Catch ex As IndexOutOfRangeException
MsgBox("You have too many items for this array!")
End Try


End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Form2.Show()
End Sub
End Class


So here I have figured out to add another form and I know how to create the histogram, but I want to use the number of entries that I enter into the listbox as the 'x-axis' and the actual data (numbers) as the 'y-axis'. How can I tell the histogram to grab the 'x' & 'y' from the listbox?

Also if I am using an array, is there a cap on how many entries I can type in? If I take the (5) out it does not work. Does there have to be some number?


Thank you.
Posted

1 solution

You are not telling 'Form2' any additional information other then it should be visible on screen. You have to do some sort of initialization process between the time that you call `Form2.Show()` and the point when it actually appear on screen.

Take a look at the `Form.Load` event for Form2. You should do some kind of action handling this event to notify your histogram of the XY information.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900