KarlTheHopeless
asked on
How to Add to a SortedList
Hi Everyone
Could someome please explain why I get the Error "Object reference not set to an instance of an object" in the following code ...
====================
Dim InputFrom As String = ""
Dim Pos As Short = 0
... ...
For i As Int16 = 1 To 24
InputFrom = LineInput(Ch("QuestionAnsw er"))
Pos = InStr(InputFrom, "/")
QuestionAnswer.Answer = Mid(InputFrom, Pos + 1)
QuestionAnswer.Question = InputFrom.Substring(0, Pos - 1)
SortedDict(QuestionAnswer. Answer) = QuestionAnswer.Question
SList.Add(QuestionAnswer.A nswer, QuestionAnswer.Question)
Next
=======================
The error occurs on the line begininng with SList.
The variables QuestionAnswer.Answer and QuestionAnswer.Question seem to be fine, in that hovering over them shows them to be correct.
Thank you
Karl
Could someome please explain why I get the Error "Object reference not set to an instance of an object" in the following code ...
====================
Dim InputFrom As String = ""
Dim Pos As Short = 0
... ...
For i As Int16 = 1 To 24
InputFrom = LineInput(Ch("QuestionAnsw
Pos = InStr(InputFrom, "/")
QuestionAnswer.Answer = Mid(InputFrom, Pos + 1)
QuestionAnswer.Question = InputFrom.Substring(0, Pos - 1)
SortedDict(QuestionAnswer.
SList.Add(QuestionAnswer.A
Next
=======================
The error occurs on the line begininng with SList.
The variables QuestionAnswer.Answer and QuestionAnswer.Question seem to be fine, in that hovering over them shows them to be correct.
Thank you
Karl
Where and How have you declared SList
ASKER
Hi Jacko
This is declared right at the beginning of the Class.
==============
Public Class frmpupwork
Inherits System.Windows.Forms.Form
Public SList As New SortedList(Of String, Object)
============
Karl
This is declared right at the beginning of the Class.
==============
Public Class frmpupwork
Inherits System.Windows.Forms.Form
Public SList As New SortedList(Of String, Object)
============
Karl
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
PERFECT
Thank Jacko
Thank Jacko
ASKER
Thanks Jacko.