1
Answer

how to display an array.

kate 0

kate 0

20y
2k
1
Hello everyone Could anyone help me, ive just started playing with vb programming, well actually programming and i am trying to display all of the values in an arraywhich i have created, my array is this: (also is this a 2 dimensional array?) Dim employee as object ( , ) = { {"Dave Keith", 47, 12.5, 13, 234563}, {"Emile Winston", 4, 31.3, 52, 9787618}, {"David Smith", 16, 12.5, 13, 234111}, {"Ronnie Serba", 74, 2.13, 12, 586943}, {"Bryan Talbot", 47, 98.5, 13, 2340003}, {"Bert Hencklman", 39, 21.3, 42, 584343}, {"Roger Davids", 86, 1.21, 11, 234563}, {"Chuck Rice", 30, 12.6, 46, 5862543}} I wish to display them all on individual forms that only appear once i click a button on my main form. i.e. on the main form there is a button named display employee records. If there is a record to display, then the first set of values,i.e. those for Dave Keith will be displayed on a form2, then if there is another set this will appear on form 3 and so on. Hopefully when i run the code i will have the main form plus one form displaying the values for each person in the array, this data for each person will be placed in text boxes or similar so i can do processing on it
Answers (1)
0
MythicalMe
NA 245 0 20y
Your second form will have all of your details. You'll use properties to display (or further process) the data: public property empName as string get return m_EmpName ' a global definition for the second form end get set (value as string) m_EmpName = value txtEmpName.Text = m_EmpName ' txtEmpName is the name of your textbox end set end property Do this for each variable on the second form. In your first form, in the button click event: dim frm = new frmSecondForm ' the name of your second form is frmSecondForm frm.EmpName = employee(0 , 0) ' this is just an example for Dave Keith frm.xxxx = employee(0, 1) ' continue with the array for each property frm.ShowDialog ' this displays the form There are many other ways to solve the problem depending on your circumstances, but this will get the job done. Incidentally, it is considered bad practice to define a variable as object. There are circumstances where it is unavoidable, but in this case you probably should define a structure: public Employee as Structure dim empName as string dim age as integer dim ..... end structure you could then define your array as a single entity: dim arrayyEmp as Employee()