Very simple question, about lists

  • Thread starter Thread starter Head_one
  • Start date Start date
H

Head_one

Guest
Hello Everybody,

It is simple but I do not know why I get an error.

1. I defined a structure with 2 fields.

2. I defined a list (my_list) of that structure.

3. I Created 2 cell of the list.

When I want to change a field of second Cell of(my_list),

I get an error.

-----------------------------

Class Form1

Structure Str_Rec ' String record

Dim Str As String

Dim Loc As String

End Structure



Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click

Dim my_list As New List(Of Str_Rec)

Dim Tmp As Str_Rec



Tmp.Str = "ABC"

Tmp.Loc = "1"

my_list.Add(Tmp)



Tmp.Str = "DEF"

Tmp.Loc = "2"

my_list.Add(Tmp)


my_list(1).Loc = "HHHH" ‘ DOES NOT WORK. I GET AN ERROR.

End Sub

End Class


my_list(1).Loc = "HHHH" Creates an error. Why is it, and how to overcome

The problem?

Thanks to all helpers.

Moshe.







All things are difficult before they are easy. (unknown)

Continue reading...
 
Back
Top