COVID-19: Choose between our familiar (but now socially distanced) classroom training courses and our excellent new live online courses.
Review of VB.NET Data Storage Structures
Part six of an eight-part series of blogs

There are a bewildering array (excuse the pun) of data storage structures available to you in Visual Basic. Choose from arrays, ArrayLists, SortedLists, Dictionaries, HashTables, Lists and DataTables, among others. This blog gives an example of each type of structure, and benchmarks them to show which perform best and worst.

  1. VB.NET Data Storage Types Compared and Benchmarked
  2. VB.NET Benchmarking Test of speeds of data structures
  3. Arrays - Visual Basic data structures
  4. ArrayLists and SortedLists - Visual Basic data structures
  5. Dictionaries and HashTables - Visual Basic data structures
  6. Lists - Visual Basic data structures (this blog)
  7. Using data tables - Visual Basic data structures
  8. Benchmark Results and Recommendations

Posted by Andy Brown on 24 August 2011

You need a minimum screen resolution of about 700 pixels width to see our blogs. This is because they contain diagrams and tables which would not be viewable easily on a mobile phone or small laptop. Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings.


A list is just a collection to which you can add items easily.  The code I used to test list performance is as follows:

Sub TestList()

Dim list As New List(Of String)


'first test: writing 10 ^ n values

Dim i As Integer

For i = 0 To (10 ^ RunSize) - 1



'work out how long this took

WriteTime = ElapsedTime

'store ten values for subsequent tests


'sort the list (timing this)


SortTime = ElapsedTime

'third test: find 10 "random" values by number

Dim s As String

For i = (10 ^ RunSize) - 1 To 0 Step -(10 ^ (RunSize - 1))

s = list(i)


'report how long this took

Read1Time = ElapsedTime

'fourth test: find 10 "random" values by name

For i = 0 To 9

s = TextValues(i)

For j = 0 To (10 ^ RunSize) - 1

If list(j) = s Then

Exit For

End If



Read2Time = ElapsedTime

'write out results of test


End Sub

The results of running this test are shown at the end of this blog.

This blog has 0 threads Add post