8 Replies - 1642 Views - Last Post: 06 March 2012 - 05:55 PM Rate Topic: -----

#1 Ailaz  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 87
  • Joined: 10-December 11

? Multidimensional arrays?

Posted 29 February 2012 - 06:53 PM

Hi All

So for those of you that don't know ..I've been generating a randomised image quiz and then saving the user info and image generated, user choice and answer to a csv file. I've also managed to pull in the csv & into the excel file. The users will send me the results.

I've been thinking about the format I will be receive the files and how I would want to manipulate the data. I would want to use "multi-dimensional arrays. " So with the user name in all of column A. The subsequent columns would be: DATE OF TEST; image file number; file path: USER RESPONSE; time taken to respond;

Help...

Is This A Good Question/Topic? 0
  • +

Replies To: ? Multidimensional arrays?

#2 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3719
  • View blog
  • Posts: 5,990
  • Joined: 08-June 10

Re: ? Multidimensional arrays?

Posted 01 March 2012 - 06:17 AM

* Moved to the VB.NET help forum *

Please try not to post your questions in the Tutorials sections.
Was This Post Helpful? 1
  • +
  • -

#3 TechnoBear  Icon User is offline

  • D.I.C Head

Reputation: 18
  • View blog
  • Posts: 222
  • Joined: 02-November 11

Re: ? Multidimensional arrays?

Posted 01 March 2012 - 09:40 AM

I'm afraid I do not understand what your asking for. Is it that you do not know how to populate the multidimensional array? or is it the you do not know how to be sent the results?

I guess I just need clarification on what it is that you are having trouble with
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9210
  • View blog
  • Posts: 34,592
  • Joined: 12-June 08

Re: ? Multidimensional arrays?

Posted 01 March 2012 - 09:44 AM

From what it sounds like you want seven columns with variable rows. That's called a dataset with a datatable. Pretty nifty and good for data manipulation.
Was This Post Helpful? 0
  • +
  • -

#5 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2263
  • View blog
  • Posts: 9,467
  • Joined: 29-May 08

Re: ? Multidimensional arrays?

Posted 01 March 2012 - 11:21 AM

Why no create a class that contains those as properties? Now you have 1D of that class, magic. See Tutorial
Was This Post Helpful? 1
  • +
  • -

#6 Ailaz  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 87
  • Joined: 10-December 11

Re: ? Multidimensional arrays?

Posted 01 March 2012 - 03:54 PM

Sorry guys ....fell asleep over macbook last night ..was reading a tutorial, wrote a question in the wrong place...and nodded off.

I'm storing results of a randomised quiz at the moment in several listboxes and then streamwriting to csv file. I was looking for a way to make the data manipulation a little niftier so I can play with data when I finally get to post this out! So include ID, Institution, Medical Grade of user, file path, image number blah di blah di blah.....Will look at everybody's suggestions....
Was This Post Helpful? 0
  • +
  • -

#7 DimitriV  Icon User is offline

  • They don't think it be like it is, but it do
  • member icon

Reputation: 584
  • View blog
  • Posts: 2,738
  • Joined: 24-July 11

Re: ? Multidimensional arrays?

Posted 01 March 2012 - 04:17 PM

There are many ways - you could use a DataGridView for it because I find it's the control of choice for data storage (personally I've never had a need for them).
Or you could write your own classes - potentially challenging but kinda fun in a way.
Was This Post Helpful? 0
  • +
  • -

#8 Ailaz  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 87
  • Joined: 10-December 11

Re: ? Multidimensional arrays?

Posted 03 March 2012 - 12:00 PM

Hmmm...need the arrays to filled dynamically (as user selects responses)......can't get into this at all...

    Private Sub Savebutton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Savebutton.Click
        oExcel = New Excel.Application
        oExcel.Visible = True
        oBook = oExcel.Workbooks.Add(String.Concat(driv, "vb\Final1\Final\Results\AllUBM.xls"))
        Dim oSheet As Object

        Dim Array(99, 4) As Object
        ' Dim r As Array
        
        For r = 0 To 99
            Array(r, 0) = "Username"
            Array(r, 1) = ListBox1.Items.Add(intPic)
            Array(r, 2) = ListBox4.Items.Add(String.Concat(stemTEST)) ' but this is ends up saves as integer ..rather than the file name.....
            Array(r, 3) = ListBox3.Items.Add(TimeString)

        Next

        'Add headers to the worksheet on row 1.
        oSheet = oBook.Worksheets(2)
        oSheet.Range("A1").Value = "User Details"  ' need to find way  of entering user details copied in to whole column.....
        oSheet.Range("B1").Value = "File path"
        oSheet.Range("C1").Value = "Random number/ ListBox2"
        oSheet.Range("D1").Value = "User response"
        oSheet.Range("E1").Value = "Time Taken"

        'Transfer the array to the worksheet starting at cell A2.
        oSheet.Range("A2").Resize(100, 3).Value = Array

        'Save the Workbook and quit Excel.
        oBook.SaveAs(String.Concat(driv, "vb\Final1\Final\Results\AllUBM.xls"))
        oSheet = Nothing
        oBook = Nothing
        oExcel.Quit()
        oExcel = Nothing
        GC.Collect()
        End


Was This Post Helpful? 0
  • +
  • -

#9 Ailaz  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 87
  • Joined: 10-December 11

Re: ? Multidimensional arrays?

Posted 06 March 2012 - 05:55 PM

So this is what I used....to compile results
Private Sub Savebutton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Savebutton.Click
        oExcel = New Excel.Application
        oExcel.Visible = True
        oBook = oExcel.Workbooks.Add(String.Concat(driv, "vb\Final1\Final\Results\AllUBM.xls"))
        Dim csvFile As String = Dir(String.Concat(driv, "vb\Final1\Final\Results\UBM1.csv"))
        Dim oBook2 As Excel.Workbook = oExcel.Workbooks.Open(String.Concat(driv, "vb\Final1\Final\Results\UBM1.csv"))
        Dim oSheet As Object
        Dim oSheeta As Object

        Dim Array(49, 5) As Object

        For s = 0 To 49
            Array(s, 0) = Login.TextBox2.Text
            Array(s, 1) = Login.TextBox3.Text
            Array(s, 2) = Login.TextBox4.Text
            Array(s, 3) = datetest
            Array(s, 4) = startTime
        Next

        oSheet = oBook.Worksheets(1) 'Add headers to the worksheet on row 1.
        oSheeta = oBook2.Worksheets(1)

        oSheet.Range("A1").Value = "Name"
        oSheet.Range("B1").Value = "Institution"
        oSheet.Range("C1").Value = "Post"
        oSheet.Range("D1").Value = "Test Date"
        oSheet.Range("E1").Value = "Start Timet"
        oSheet.Range("A1:I1").Font.Bold = True

        oSheet.Range("A2").Resize(49, 5).Value = Array 'Transfer the array to the worksheet starting at cell A2.


        CType(oSheeta, Excel.Worksheet).Range("A1:D50").Copy()
        CType(oSheet, Excel.Worksheet).Range("F1").PasteSpecial(Excel.XlPasteType.xlPasteAll)
        oSheet.Columns.Autofit()
        oSheet.Range("A1:I1").Font.Bold = True

        oBook.SaveAs(String.Concat(driv, "vb\Final1\Final\Results\AllUBM.xls")) 'Save the Workbook and quit Excel.
        oSheet = Nothing
        oSheeta = Nothing
        oBook2 = Nothing
        oBook = Nothing
        oExcel.Quit()
        oExcel = Nothing
        GC.Collect()
        End
        ExitButton.Enabled = True

End Sub
:bananaman:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1