I'm getting a key not found error which I can't understand, since the
key appears to be in the dictionary.
The dictionary is populated by the following routine:
Dim F As FolderItem
Dim S As TextInputStream
Dim VNum As Integer
Dim V As Vehicle
VehicleDict = New Dictionary
VehiclePop.DeleteAllRows
F = PreferencesFolder.Child("JAUSPrefs.txt")
If F <> Nil Then
S = F.OpenAsTextFile
If S <> Nil Then
IPEdt.Text = S.ReadLine
PortEdt.Text = S.ReadLine
While Not S.EOF
VNum = Cdbl(S.ReadLine) //<-----here
to
VehiclePop.AddRow Cstr(VNum)
V = New Vehicle
V.ID = VNum
VehicleDict.Value(VNum) = V //<--- here
Wend
S.Close
//<---- breakpoint here
Else
Dim M As New MessageDialog
M.Icon = MessageDialog.GraphicCaution
M.Title = "Data Read Failure"
M.Message = "Unable to read data"
M.Explanation = "The IP address, port and vehicle list were not
read."
Call M.ShowModal
End If
End If
In the lines marked "here to here," this routine reads a file and
creates a member of the vehicle class for each vehicle number in the
file. If I put a breakpoint at the S.Close statement, I can look at the
dictionary and see that it has 5 entries with keys of 1, 38, 49, 54 and
67, which is exactly what I would expect, knowing that those vehicle
numbers are in the file.
Shortly after that, I run another routine that wants to make an addition
to the dictionary entry for one of the vehicles. The first lines of that
routine are:
Dim V As Vehicle
V = VehicleDict.Value(CDbl(VehiclePop.Text)) //<---------- key not
found
I am getting a Key Not Found error at the second statement. In the
debugger, the value of VehiclePop.Text is "1" and the dictionary still
has be 5 entries (keys of 1, 38, 49, 54 and 67), so it appears that the
key really is there.
I am running RB2006r2 on Win XP Pro. Any ideas?
Paul Dobbs
Software Engineer, Staff
Lockheed Martin Missiles and Fire Control
Phone (972) 603-1244
Fax (972) 603-2017
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>