Sort table filled from csv-file

BasicBert

Member
Licensed User
Longtime User
In the app I'm making now, I have to read in a CSV-file (originating from Excel) into a List called Table. This works well by using LoadCSV2 from the StringUtils library :

B4X:
Table = su.LoadCSV2(File.DirRootExternal, PathAndFilenameDAT, ",", lstHeader)

Then I load the headers into two spinners for later use :

B4X:
For i = 0 To lstHeader.Size-2            'Last column in CSV-file is empty, so don't use
      spnFirstLine.Add(lstHeader.Get(i))      
      spnSecondLine.Add(lstHeader.Get(i))      
Next
spnFirstLine.SelectedIndex = Header1
spnSecondLine.SelectedIndex = Header2
In the rest of the app I can work with the data in the List (Table) by getting a row (i) of data with :

B4X:
sColumn = Table.Get(i)
and referencing to the individual columns with sColumn(x), where x is a reference to the column I need.

At the moment the list (Table) contains about 190 rows of about 46 columns.
From this Table some listviews are filled and shown on screen one at a time, selected by the user. From these listviews the user chooses an item. This opens a panel with details derived from Table.

So far everything works OK and I'm happy with the app as is.
But....

I would like to be able to sort the list on any of the columns, but I don't know how. Of course I tried reading the forums, User Guide and Beginner's Guide but never came far. Table.Sort(true) does not work but gives a java error :
LastException java.lang.ClassCastExeption:java.lang.String[] cannot be cast to java.lang.Comparable.

:sign0163:
 

BasicBert

Member
Licensed User
Longtime User
Erel, thanks for replying.
I have read the DBUtils and SQL tutorials before, but I don't think I can master that in the time I have available now. That will have to wait.

Now, let me rephrase my question to steer me in a direction I think (hope) that can bring me what I want.

Since I found out that sorting of an array of Type-variables is quite easy with Table.SortType("field",true), I would like to use that if possible.
I have been experimenting with an example found on the forum, that works fine. But I'm not very successfull yet in implementing this in the real app.

Problem is getting the csv-file into this Type-array with StringUtils.

The code for my test is :
B4X:
'Activity module
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.
   Type Data(Naam As String, Kleur As String, Soort As String, Jaar As String, Land As String, _
   Gebied As String, Streek As String, Appelation As String, Cepage1 As String, CepProc1 As String, _
   Cepage2 As String, CepProc2 As String, Cepage3 As String, CepProc3 As String, Cepage4 As String, _
   CepProc4 As String, Alcohol As String, Inhoud As String, Temperatuur As String, Producent As String, _
   Website As String, DrinkVanaf As String, DrinkTot As String, DatumGekocht As String, Tgv As String, _
   GiftVan As String, GiftAan As String, Leverancier As String, Betaald As String, AantalGekocht As String, _
   AantalResterend As String, AantalGedronken As String, TotaleWaarde As String, ResterendeWaarde As String, _
   OpgedronkenWaarde As String, Opslagplaats As String, Bijzonderheden As String, Proefnotitie As String, _
   Waardering As String, LaatstGedronken As String, Afbeelding As String, ID As String, LaatstGewijzigd As String, _
   Wissen As String, Leeg As String, WaardeFles As String)
End Sub

Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.

End Sub

Sub Activity_Create(FirstTime As Boolean)
    Dim Table As List
    Table.Initialize
   
    For i = 1 To 50
        Dim Kolom As Data
        Kolom.Naam = "Person" & i
        Kolom.AantalResterend = Rnd(0, 121)
      'other fields in Kolom.xxx remain empty for testing
        Table.Add(Kolom)
    Next
   'Above For Next loop should be replaced with loading the CSV-file
    Table.SortType("Naam", True) 'Sort the list based on the Naam field.
    For i = 0 To Table.Size - 1
        Dim Regel As Data
        Regel = Table.Get(i)
        Log(Regel)
      Log("-------------------------------------")
    Next
   
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Using the Type-variable also has an advantage in refering to the fields further in my app because Kolom.Naam or Kolom.AantalResterend is more descriptive than sColumn(0) or sColumn(34) as it is now.

I hope you can point me in the good direction.
 
Upvote 0

BasicBert

Member
Licensed User
Longtime User
Erel, thanks again for your reply.

Your answer seems logical and I'll try that in a testprogram before reworking the current app.

:sign0188:
 
Upvote 0

BasicBert

Member
Licensed User
Longtime User
1. Read the CSV file to a list of arrays with StringUtils2.
2. Create a second list.
3. Go over all the arrays in the first list, create a type instance for each one and add it to the second list.
4. Sort the second list with List.SortType.

These steps seem feasable and understandable to me, so I tried to implement them in my testprogram.

Just for testing I use the Log-statement and no layouts. I would like to show the logs here, but I can't find them on the device or PC, nor can I copy/paste (???) it from the IDE.

Step 1 is no problem.
Step 2 seems to work.
Step 3 The second list seems to be filled with the right number of "records", but all records have the same data in it : the last record from OldList.
Step 4 has no use untill step 3 is right.

Here is the code I used :
B4X:
'Activity module
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.
   Type Data(Naam As String, Kleur As String, Soort As String, Jaar As String, Land As String, _
   Gebied As String, Streek As String, Appelation As String, Cepage1 As String, CepProc1 As String, _
   Cepage2 As String, CepProc2 As String, Cepage3 As String, CepProc3 As String, Cepage4 As String, _
   CepProc4 As String, Alcohol As String, Inhoud As String, Temperatuur As String, Producent As String, _
   Website As String, DrinkVanaf As String, DrinkTot As String, DatumGekocht As String, Tgv As String, _
   GiftVan As String, GiftAan As String, Leverancier As String, Betaald As String, AantalGekocht As String, _
   AantalResterend As String, AantalGedronken As String, TotaleWaarde As String, ResterendeWaarde As String, _
   OpgedronkenWaarde As String, Opslagplaats As String, Bijzonderheden As String, Proefnotitie As String, _
   Waardering As String, LaatstGedronken As String, Afbeelding As String, ID As String, LaatstGewijzigd As String, _
   Wissen As String, Leeg As String, WaardeFles As String)
   Dim su As StringUtils
   Dim NewTable As List
    Dim OldTable As List
   Dim Kolom As Data
End Sub

Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.
   Dim PathAndFilenameDAT As String :    PathAndFilenameDAT = "DropboxSync/Wijnopslag/Wijnopslag.dat"
   Dim lstHeader As List
End Sub

Sub Activity_Create(FirstTime As Boolean)
    OldTable.Initialize
   NewTable.initialize   

'Step 1 : read CSV-file
   OldTable = su.LoadCSV2(File.DirRootExternal, PathAndFilenameDAT, ",", lstHeader)
'Don't use lstHeader now, later in the app this will be used

'Step 2 : Read OldTable into Array Regel(),
'then assign each Array-element to the corresponding part of the Type
   For i = 0 To OldTable.Size-1
      Dim Regel() As String
      Regel = OldTable.Get(i)
      Kolom.Naam = Regel(0)
      Kolom.Kleur = Regel(1)
      Kolom.Soort = Regel(2)
      Kolom.Jaar = Regel(3)
      Kolom.Land = Regel(4)
      Kolom.Gebied = Regel(5)
      Kolom.Streek = Regel(6)
      Kolom.Appelation = Regel(7)
      Kolom.Cepage1 = Regel(8)
      Kolom.CepProc1 = Regel(9)
      Kolom.Cepage2 = Regel(10)
      Kolom.CepProc2 = Regel(11)
      Kolom.Cepage3 = Regel(12)
      Kolom.CepProc3 = Regel(13)
      Kolom.Cepage4 = Regel(14)
      Kolom.CepProc4 = Regel(15)
      Kolom.Alcohol = Regel(16)
      Kolom.Inhoud = Regel(17)
      Kolom.Temperatuur = Regel(18)
      Kolom.Producent = Regel(19)
      Kolom.Website = Regel(20)
      Kolom.DrinkVanaf = Regel(21)
      Kolom.DrinkTot = Regel(22)
      Kolom.DatumGekocht = Regel(23)
      Kolom.Tgv = Regel(24)
      Kolom.GiftVan = Regel(25)
      Kolom.GiftAan = Regel(26)
      Kolom.Leverancier = Regel(27)
      Kolom.Betaald = Regel(28)
      Kolom.AantalGekocht = Regel(29)
      Kolom.AantalResterend = Regel(30)
      Kolom.AantalGedronken = Regel(31)
      Kolom.TotaleWaarde = Regel(32)
      Kolom.ResterendeWaarde = Regel(33)
      Kolom.OpgedronkenWaarde = Regel(34)
      Kolom.Opslagplaats = Regel(35)
      Kolom.Bijzonderheden = Regel(36)
      Kolom.Proefnotitie = Regel(37)
      Kolom.Waardering = Regel(38)
      Kolom.LaatstGedronken = Regel(39)
      Kolom.Afbeelding = Regel(40)
      Kolom.ID = Regel(41)
      Kolom.LaatstGewijzigd = Regel(42)
      Kolom.Wissen = Regel(43)
      Kolom.Leeg = Regel(44)
      Kolom.WaardeFles = Regel(45)
'Add it to NewTable
      NewTable.Add(Kolom)
'See what's happening :
      Log(Kolom)
      Log(NewTable.Size)
      Log ("==============================")
   Next
'Up to here everything works as expected, the log shows all 190 different items with an expending size.

'Step 3 :
'In the next For-loop every iteration will bring back the last item that was put to NewTable !!!!
'So I get 190 times the same values!!!
   For i = 0 To NewTable.Size-1
      Kolom = NewTable.Get(i)
      Log(i+1)
      Log(Kolom)
      Log("------------------------------")
   Next
'Step 4
'   newTable.SortType("Naam", True)

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

My sense of logic says NewTable.Add(Kolom) is not doing as I expect, although the Log(NewTable.Size) tells me the new table is growing with exact the number of record from the OldList. But WHY only the last record of OldList will be used allover in NewList ???

:BangHead:
 
Upvote 0

raphaelcno

Active Member
Licensed User
Longtime User
I think the problem is that in step 3 you use the global variable Kolom used to generate NewTable.
You can try to use a different variable:

B4X:
'Step 3 :
    For i = 0 To NewTable.Size-1
        Dim Kolom2 As Data  ' NB: Kolom2 or anything different than the global variable Kolom
        Kolom2 = NewTable.Get(i)
        Log(i+1)
        Log(Kolom2)
        Log("------------------------------")
    Next

I hope this will help.
 
Upvote 0

BasicBert

Member
Licensed User
Longtime User
@raphaelcno :
Thanks for replying, but sorry, this doesn't do the trick.
I was thinking the same already and have tried exactly what you suggest (Kolom2 instead of Kolom in step 3). Result is the same.

If this would have helped, there must be a bug in handling variables and arays/lists, because it would mean that Kolom would not be updated and loaded with data from the statement
B4X:
Kolom2 = NewTable.Get(i)

One difference with what I tried is that you dim Kolom2 in this routine, not as a Global.
I'll see what that does, tonight.

I also checked to see if the for/next was counting OK, starting with 0. Even tried using another index in the for/next (e.g. j instead of i). But no change....
:sign0163:
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Change this:
B4X:
 For i = 0 To OldTable.Size-1
        Dim Regel() As String
        Regel = OldTable.Get(i)
        Kolom.Naam = Regel(0)
To:
B4X:
 For i = 0 To OldTable.Size-1
 Dim Kolom As Data 'creates a new object
 Kolom.Initialize
        Dim Regel() As String
        Regel = OldTable.Get(i)
        Kolom.Naam = Regel(0)

See the "common mistake" described here:
Variables & Objects in Basic4android
 
Upvote 0

BasicBert

Member
Licensed User
Longtime User
Erel, thanks again.
I'll give it a try later today.

Just from looking at your reaction I understand that I have to dimension and initialize my type variable Kolom within every iteration through the for/next loop.
If it works, I'll accept it, but it looks strange for me.
I would expect a new dimension and initialize of Kolom just before the for/next loop and more so on the loop in part 3 then in part 2.

I'll look at the suggested "common mistakes" too.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I would expect a new dimension and initialize of Kolom just before the for/next loop and more so on the loop in part 3 then in part 2.
You should not expect that.

You are assigning different values to the object fields. The compiler should not implicitly create a new object. It cannot know that you do not want to update the current object.
 
Upvote 0

BasicBert

Member
Licensed User
Longtime User
You should not expect that.
:sign0142:



You are assigning different values to the object fields. The compiler should not implicitly create a new object. It cannot know that you do not want to update the current object.

I am starting to see the problem (vague, but clearing up slowly).

As you say I should not expect things :), but what I expected was that
B4X:
NewTable.Add(Kolom)
writes the current contents of Kolom to the Table (list) and in the next iteration adds the new values of Kolom to the end of the same list.
The log pointed me in that way, too. But that could have been the way I put the Log-commands in the code.
Maybe Log(NewTable) could have shown otherwise.

Can't wait to try this all tonight.
 
Upvote 0

BasicBert

Member
Licensed User
Longtime User
:sign0142:
As you say I should not expect things :), but what I expected was that
B4X:
NewTable.Add(Kolom)
writes the current contents of Kolom to the Table (list) and in the next iteration adds the new values of Kolom to the end of the same list.
The log pointed me in that way, too. But that could have been the way I put the Log-commands in the code.
Maybe Log(NewTable) could have shown otherwise.

Can't wait to try this all tonight.

Why even bother to question Erel's answers???
The guy has been declared a genius many times on this forum.
Maybe it's just us simpler geniuses that have trouble understanding him.
:sign0027:

Just added the declaration he mentioned and it worked instantly.:sign0188:.
The reference to the "common mistakes" is also to the point. Yes, I did read that before, but it didn't occur to me that this handled my problem.

There's a lot to learn for me, here. That's why I'm a :sign0104:

Thanks Erel!
 
Upvote 0

raphaelcno

Active Member
Licensed User
Longtime User
So it means you declare Kolom in the For routine when you genrate the old table, and you use the global Kolom when you generate the new table. Is that correct?
Maybe you can show us the final code to be sure that we understand right.
 
Upvote 0

BasicBert

Member
Licensed User
Longtime User
So it means you declare Kolom in the For routine when you genrate the old table, and you use the global Kolom when you generate the new table. Is that correct?

No, that's not correct, I think. In the final code I removed the Dim-statement for Kolom from the Sub Process_Globals, and placed it like Erel suggested in the for/next loop.
Because I needed Kolom in other routines also, I had rather have Kolom as a Process_Global or Global, instead of a Local as it is now. But then the code would not work...
So I'll reference the other subs that I need Kolom in with Kolom as an argument. But that's not in this test program.

Maybe you can show us the final code to be sure that we understand right.

B4X:
'Activity module
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.
   Type Data(Naam As String, Kleur As String, Soort As String, Jaar As String, Land As String, _
   Gebied As String, Streek As String, Appelation As String, Cepage1 As String, CepProc1 As String, _
   Cepage2 As String, CepProc2 As String, Cepage3 As String, CepProc3 As String, Cepage4 As String, _
   CepProc4 As String, Alcohol As String, Inhoud As String, Temperatuur As String, Producent As String, _
   Website As String, DrinkVanaf As String, DrinkTot As String, DatumGekocht As String, Tgv As String, _
   GiftVan As String, GiftAan As String, Leverancier As String, Betaald As String, AantalGekocht As String, _
   AantalResterend As String, AantalGedronken As String, TotaleWaarde As String, ResterendeWaarde As String, _
   OpgedronkenWaarde As String, Opslagplaats As String, Bijzonderheden As String, Proefnotitie As String, _
   Waardering As String, LaatstGedronken As String, Afbeelding As String, ID As String, LaatstGewijzigd As String, _
   Wissen As String, Leeg As String, WaardeFles As String)
   Dim su As StringUtils
   Dim NewTable As List
    Dim OldTable As List
End Sub

Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.
   Dim PathAndFilenameDAT As String :    PathAndFilenameDAT = "DropboxSync/Wijnopslag/Wijnopslag.dat"
   Dim lstHeader As List
End Sub

Sub Activity_Create(FirstTime As Boolean)
    OldTable.Initialize
   NewTable.initialize   

'Step 1 : read CSV-file
   OldTable = su.LoadCSV2(File.DirRootExternal, PathAndFilenameDAT, ",", lstHeader)
'Don't use lstHeader now, later in the app this will be used

'Step 2 : Read OldTable into Array Regel(),
'then assign each Array-element to the corresponding part of the Type
   For i = 0 To OldTable.Size-1
      Dim Kolom As Data
      Kolom.Initialize
      Dim Regel() As String
      Regel = OldTable.Get(i)
      Kolom.Naam = Regel(0)
      Kolom.Kleur = Regel(1)
      Kolom.Soort = Regel(2)
      Kolom.Jaar = Regel(3)
      Kolom.Land = Regel(4)
      Kolom.Gebied = Regel(5)
      Kolom.Streek = Regel(6)
      Kolom.Appelation = Regel(7)
      Kolom.Cepage1 = Regel(8)
      Kolom.CepProc1 = Regel(9)
      Kolom.Cepage2 = Regel(10)
      Kolom.CepProc2 = Regel(11)
      Kolom.Cepage3 = Regel(12)
      Kolom.CepProc3 = Regel(13)
      Kolom.Cepage4 = Regel(14)
      Kolom.CepProc4 = Regel(15)
      Kolom.Alcohol = Regel(16)
      Kolom.Inhoud = Regel(17)
      Kolom.Temperatuur = Regel(18)
      Kolom.Producent = Regel(19)
      Kolom.Website = Regel(20)
      Kolom.DrinkVanaf = Regel(21)
      Kolom.DrinkTot = Regel(22)
      Kolom.DatumGekocht = Regel(23)
      Kolom.Tgv = Regel(24)
      Kolom.GiftVan = Regel(25)
      Kolom.GiftAan = Regel(26)
      Kolom.Leverancier = Regel(27)
      Kolom.Betaald = Regel(28)
      Kolom.AantalGekocht = Regel(29)
      Kolom.AantalResterend = Regel(30)
      Kolom.AantalGedronken = Regel(31)
      Kolom.TotaleWaarde = Regel(32)
      Kolom.ResterendeWaarde = Regel(33)
      Kolom.OpgedronkenWaarde = Regel(34)
      Kolom.Opslagplaats = Regel(35)
      Kolom.Bijzonderheden = Regel(36)
      Kolom.Proefnotitie = Regel(37)
      Kolom.Waardering = Regel(38)
      Kolom.LaatstGedronken = Regel(39)
      Kolom.Afbeelding = Regel(40)
      Kolom.ID = Regel(41)
      Kolom.LaatstGewijzigd = Regel(42)
      Kolom.Wissen = Regel(43)
      Kolom.Leeg = Regel(44)
      Kolom.WaardeFles = Regel(45)
'Add it to NewTable
      NewTable.Add(Kolom)
   Next
   NewTable.SortType("Gebied", True) 'Just to show sorting works on NewTable and doesn't have to wait for step 4
'Step 3 :
   For i = 0 To NewTable.Size-1
      Kolom = NewTable.Get(i)
      Log(i+1)
      Log(Kolom)
      Log("------------------------------")
   Next
'Step 4
'   NewTable.SortType("Naam", True)   'Here NewTable can be sorted also

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

I think I could move DIM OldTable as List to be local also, because it will never be used again.
B4X:
Sub Activity_Create(FirstTime As Boolean)
    Dim OldTable as List
    OldTable.Initialize
    NewTable.initialize
 
Upvote 0

raphaelcno

Active Member
Licensed User
Longtime User
I've also seen some of my code where I use a similar loop, and I think you can move "Dim Regel() As String" before "For i = 0 To OldTable.Size-1":

B4X:
'Step 1 : read CSV-file
    OldTable = su.LoadCSV2(File.DirRootExternal, PathAndFilenameDAT, ",", lstHeader)
'Don't use lstHeader now, later in the app this will be used

'Step 2 : Read OldTable into Array Regel(),
'then assign each Array-element to the corresponding part of the Type
    Dim Regel() As String  ' <== Moved from the For loop
    For i = 0 To OldTable.Size-1
        Dim Kolom As Data
        Kolom.Initialize
        Regel = OldTable.Get(i)
        Kolom.Naam = Regel(0)
        Kolom.Kleur = Regel(1)
        ' [...]
        Kolom.Leeg = Regel(44)
        Kolom.WaardeFles = Regel(45)
        'Add it to NewTable
        NewTable.Add(Kolom)
    Next
 
Upvote 0

BasicBert

Member
Licensed User
Longtime User
Originally Posted by raphaelcno:
I've also seen some of my code where I use a similar loop, and I think you can move "Dim Regel() As String" before "For i = 0 To OldTable.Size-1":

You are right, I tested that and it works OK.

As for using this in my app, I must say that it worked fine also.

Originally Posted by BasicBert:
Using the Type-variable also has an advantage in refering to the fields further in my app because Kolom.Naam or Kolom.AantalResterend is more descriptive than sColumn(0) or sColumn(34) as it is now.
This really looked nice in my app, but for other reasons I got back to the original way and use the routine to convert the original table to a data-type table, sort this last one and convert it back.
A bit cumbersome, but it works and keeps me from having to change a lot more to be able to do some other things I already did in the app.

You cannot use List.Sort as the items are not numeric values or strings (they are arrays).
This way I create my own List.Sort.

This is the Convert - Sort - Convert back routine I'm using now. I used Table instead of OldTable and Dummy insted of NewTable, but you'll see the likeness :
B4X:
Sub SortTable
'Convert String-array Table to Data-type Dummy, because Data-type can be sorted easier
   Dummy.Initialize
   Dim Regel(46) As String
   For i = 0 To Table.Size-1
      Dim Kolom As Data
      Kolom.Initialize
      Regel = Table.Get(i)
      Kolom.Naam = Regel(0)
      Kolom.Kleur = Regel(1)
      Kolom.Soort = Regel(2)
      Kolom.Jaar = Regel(3)
      Kolom.Land = Regel(4)
      Kolom.Gebied = Regel(5)
      Kolom.Streek = Regel(6)
      Kolom.Appelation = Regel(7)
      Kolom.Cepage1 = Regel(8)
      Kolom.CepProc1 = Regel(9)
      Kolom.Cepage2 = Regel(10)
      Kolom.CepProc2 = Regel(11)
      Kolom.Cepage3 = Regel(12)
      Kolom.CepProc3 = Regel(13)
      Kolom.Cepage4 = Regel(14)
      Kolom.CepProc4 = Regel(15)
      Kolom.Alcohol = Regel(16)
      Kolom.Inhoud = Regel(17)
      Kolom.Temperatuur = Regel(18)
      Kolom.Producent = Regel(19)
      Kolom.Website = Regel(20)
      Kolom.DrinkVanaf = Regel(21)
      Kolom.DrinkTot = Regel(22)
      Kolom.DatumGekocht = Regel(23)
      Kolom.Tgv = Regel(24)
      Kolom.GiftVan = Regel(25)
      Kolom.GiftAan = Regel(26)
      Kolom.Leverancier = Regel(27)
      Kolom.Betaald = Regel(28)
      Kolom.AantalGekocht = Regel(29)
      Kolom.AantalResterend = Regel(30)
      Kolom.AantalGedronken = Regel(31)
      Kolom.TotaleWaarde = Regel(32)
      Kolom.ResterendeWaarde = Regel(33)
      Kolom.OpgedronkenWaarde = Regel(34)
      Kolom.Opslagplaats = Regel(35)
      Kolom.Bijzonderheden = Regel(36)
      Kolom.Proefnotitie = Regel(37)
      Kolom.Waardering = Regel(38)
      Kolom.LaatstGedronken = Regel(39)
      Kolom.Afbeelding = Regel(40)
      Kolom.ID = Regel(41)
      Kolom.LaatstGewijzigd = Regel(42)
      Kolom.Wissen = Regel(43)
      Kolom.Leeg = Regel(44)
      Kolom.WaardeFles = Regel(45)
      Dummy.Add(Kolom)
   Next
   'Table is in Dummy, now sort it
   Dummy.SortType(SortHeader(Header1), SortOrder)
   'Convert Data-type Dummy back to String-array Table
   Table.Initialize
   Dim Kolom As Data
   Kolom.Initialize
   For i = 0 To Dummy.Size-1
      Dim Regel(46) As String
      Kolom = Dummy.Get(i)
      Regel(0) = Kolom.Naam
      Regel(1) = Kolom.Kleur
      Regel(2) = Kolom.Soort
      Regel(3) = Kolom.Jaar
      Regel(4) = Kolom.Land
      Regel(5) = Kolom.Gebied
      Regel(6) = Kolom.Streek
      Regel(7) = Kolom.Appelation 
      Regel(8) = Kolom.Cepage1
      Regel(9) = Kolom.CepProc1
      Regel(10) = Kolom.Cepage2 
      Regel(11) = Kolom.CepProc2
      Regel(12) = Kolom.Cepage3
      Regel(13) = Kolom.CepProc3
      Regel(14) = Kolom.Cepage4
      Regel(15) = Kolom.CepProc4
      Regel(16) = Kolom.Alcohol
      Regel(17) = Kolom.Inhoud
      Regel(18) = Kolom.Temperatuur
      Regel(19) = Kolom.Producent
      Regel(20) = Kolom.Website
      Regel(21) = Kolom.DrinkVanaf
      Regel(22) = Kolom.DrinkTot
      Regel(23) = Kolom.DatumGekocht
      Regel(24) = Kolom.Tgv
      Regel(25) = Kolom.GiftVan
      Regel(26) = Kolom.GiftAan
      Regel(27) = Kolom.Leverancier
      Regel(28) = Kolom.Betaald
      Regel(29) = Kolom.AantalGekocht
      Regel(30) = Kolom.AantalResterend
      Regel(31) = Kolom.AantalGedronken
      Regel(32) = Kolom.TotaleWaarde
      Regel(33) = Kolom.ResterendeWaarde
      Regel(34) = Kolom.OpgedronkenWaarde
      Regel(35) = Kolom.Opslagplaats
      Regel(36) = Kolom.Bijzonderheden
      Regel(37) = Kolom.Proefnotitie
      Regel(38) = Kolom.Waardering
      Regel(39) = Kolom.LaatstGedronken
      Regel(40) = Kolom.Afbeelding
      Regel(41) = Kolom.ID
      Regel(42) = Kolom.LaatstGewijzigd
      Regel(43) = Kolom.Wissen
      Regel(44) = Kolom.Leeg
      Regel(45) = Kolom.WaardeFles
      Table.Add(Regel)
   Next
End Sub
I encountered the same problem with the Table being filled with only the last item from the original table, which means I still did not see exactly how it was supposed to be :BangHead:. But I knew what to look for and got it right :eek:
 
Upvote 0
Top