I have a Structure declared like this:
Private Structure stCat
Public CatID As Integer
Public IsOnsite As Boolean
Public RndNum As Integer
I have a List(of) declared like this:
Private colJudgeCats As List(Of stCat)
I fill that List like this:
colJudgeCats = New List(Of stCat)
For Each dtrCats As DataRow In dsCats.Tables(0).Rows
Dim pCat As New stCat
.CatID = dtrCats.Item("iCatID")
.IsOnsite = dtrCats.Item("bOnSite")
The Dataset (dsCats) contains the data, and the data fills correctly (currently from an Access database).
I then attempt to update the data in the List like this:
Public Function AddJudgeToCategory(ByVal CatID As Long, ByVal IsOnsite As Boolean) As Boolean
Dim i As Integer
For i = 0 To colJudgeCats.Count
If colJudgeCats(i).CatID = CatID Then
colJudgeCats(i).IsOnsite = IsOnsite
I recieve a compile error this, with this section highlighted:
The Error is "Expression is a value and therefore cannot be the target of an assignment"
I can get around this by using classes (which is what I've done), but I was curious as to why I'm not able to update a Member of a List in this fashion. Is there something I'm missing, or can I not use a List in this fashion? Should I use some other form of collection object? I don't want to use Datasets for various reasons, and would instead prefer to allow each of my classes to maintain their own collections/lists.