0

So I've been making a 'database' that would store different students ID's, names and grades. And the problem I'm having is that the my structure has no 'depth' and I can only store one set of data inside it. How would I increase the capacity of my structure so I'm able to store more than 1 set of data? My code is this:

Structure record
    Dim ID As Integer
    Dim fname As String
    Dim sName As String
    Dim grade As String
End Structure
Ňɏssa Pøngjǣrdenlarp
  • 38,411
  • 12
  • 59
  • 178
AnB
  • 1
  • 2

1 Answers1

0

Convert your struct to a class:

Class clsRecord

    public ID As Integer

    public fname As String

    public sName As String

    public grade As String

end class

Create a List to hold a collection of Record Classes

Dim lstRecords as List(Of clsRecord)

Create new instance of class clsRecord Dim someRecord as new clsRecord

Populate members eg

someRecord.ID = 1

Add class to collection

lstRecord.Add(someRecord)

Repeat

Then loop through collection for each record

For Each xRecords in lstRecords

    'do something

Next
WilRogJr
  • 26
  • 5
  • Why would I use class over struct? – AnB Oct 21 '16 at 21:52
  • @AnB [Structures and Classes (Visual Basic)](https://msdn.microsoft.com/en-us/library/2hkbth2a.aspx) and also [Choosing Between Class and Struct](https://msdn.microsoft.com/en-us/library/ms229017(v=vs.110).aspx) – Ňɏssa Pøngjǣrdenlarp Oct 22 '16 at 00:08