2
Answers

how can i display my array over multiple forms?

kate 0

kate 0

19y
1.8k
1
I have an array currrently containing data for 7 employees, i wish to click on a button in form 1 and then forms 2 through to 8(or however many are required to satisfy array size) be created to display the data for each employee. The data is to be displayed in textboxes on each form. i.e. form 2 will display data for Dave and will have a button to form 3 to display data for Emile, etc etc Currently my code (which is below) is placing all the data on new instances of form2 and i don't know how i can navigate round i.e from the first instance of form2 'Dave' to the second instance 'Emile', i have to close down a form to see whatever employee data is on the form behind it. Does anyone know how to achieve the creation of new forms, display the data on these new forms and then provide functionality to navigate between these new forms all through a button click on form1? Form1 vb code: Public employee As Object(,) = {{"Dave", 105, 4, 14.8, 3.47, 1.06, 4.04, 4.03}, _ {"Emile", 120, 5.55, 16.1, 3.93, 1.2, 4.7, 4.74}, _ {"Daniel", 152, 6.38, 21.1, 4.9, 1.2, 6.02, 4.23}, _ {"Ron", 101, 4, 13.6, 3.4, 0, 3.83, 3.79}, _ {"Bryan", 121, 5.55, 15.8, 3.93, 0, 5.83, 4.64}, _ {"Bert", 150, 6.25, 20, 5, 0, 5.13, 4.67}, _ {"Chuck", 265, 6.7, 17.7, 3.7, 0, 4.5, 4.44}} Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim i As Integer = 0 For i = 0 To UBound(employee) Dim F As New Form2(employee(i, 0).ToString(), _ CType(employee(i, 1), String), _ CType(employee(i, 2), Single), _ CType(employee(i, 3), Single), _ CType(employee(i, 4), Single), _ CType(employee(i, 5), Single), _ CType(employee(i, 6), Single), _ CType(employee(i, 7), Single)) F.Show() Next End Sub Form2 vb code: Form2 vb code: Public Sub New(ByVal name As String, _ ByVal data1 As Single, _ ByVal data2 As Single, _ ByVal data3 As Single, _ ByVal data4 As Single, _ ByVal data5 As Single, _ ByVal data6 As Single) MyBase.New() Me.InitializeComponent() txtname.Text = name txtdata1.Text = data1.ToString txtdata2.Text = data2.ToString txtdata3.Text = data3.ToString txtdata4.Text = data4.ToString txtdata5.Text = data5.ToString txtdata6.Text = data6.ToString txtdata7.Text = data7.ToString End Sub
Answers (2)