VB 2008 - Index was outside the bounds of the array
Posted
by Jan
on Stack Overflow
See other posts from Stack Overflow
or by Jan
Published on 2010-04-30T09:53:04Z
Indexed on
2010/04/30
9:57 UTC
Read the original article
Hit count: 173
Hey guys I'm having a problem while reading a config.cfg file of my program. I can read the 23. char of the file but I can't read the 24. char (last char in file).
This is the code:
Dim CFGReader2 As System.IO.StreamReader
CFGReader2 = _
My.Computer.FileSystem.OpenTextFileReader(CurDir() & "\Config.cfg")
Dim Server(2) As String
Server(0) = CFGReader2.ReadToEnd.Chars(23)//This part works
If Server(0) = 0 Then
Server(1) = CFGReader2.ReadToEnd.Chars(24)//This part results in "Index was outside the bounds of the array".
ElseIf Server(0) = 1 Then
Server(2) = CFGReader2.ReadToEnd.Chars(24)//This part results in "Index was outside the bounds of the array".
Server(1) = 10 + Server(2)
ElseIf Server(0) = 2 Then
Server(2) = CFGReader2.ReadToEnd.Chars(24)//This part results in "Index was outside the bounds of the array".
Server(1) = 20 + Server(2)
ElseIf Server(0) = 3 Then
Server(2) = CFGReader2.ReadToEnd.Chars(24)//This part results in "Index was outside the bounds of the array".
Server(1) = 30 + Server(2)
End If
And this is the file:
Language = 2
Server = 11
Thanks for the answer!
Frosty
© Stack Overflow or respective owner