I am trying to take text from a txt file and split it into an array so I can then place each piece of text into three seperate list boxes. I come up with an error when at Safe(x).Username = ar(1). The error is as follows:
An unhandled exception of type 'System.IndexOutOfRangeException' occurred in system.windows.forms.dll
Additional information: Index was outside the bounds of the array.
I will put the code below:
If File.Exists(SafeFile) Then
Dim ar(3) As String
Dim SR As StreamReader
Dim STR As String
SR = File.OpenText(SafeFile)
Do Until SR.Peek = -1
STR = SR.ReadLine
ar = STR.Split(vbTab)
'add The websites
Safe(x).Website = ar(0)
LstWebSites.Items.Add(Safe(x).Website)
'Add the usernames
Safe(x).Username = ar(1)
LstWebSites.Items.Add(Safe(x).Username)
'add the passwords.
Safe(x).Password = ar(2)
LstWebSites.Items.Add(Safe(x).Password)
x += 1
Loop
Thank you for your help.
An unhandled exception of type 'System.IndexOutOfRangeException' occurred in system.windows.forms.dll
Additional information: Index was outside the bounds of the array.
I will put the code below:
If File.Exists(SafeFile) Then
Dim ar(3) As String
Dim SR As StreamReader
Dim STR As String
SR = File.OpenText(SafeFile)
Do Until SR.Peek = -1
STR = SR.ReadLine
ar = STR.Split(vbTab)
'add The websites
Safe(x).Website = ar(0)
LstWebSites.Items.Add(Safe(x).Website)
'Add the usernames
Safe(x).Username = ar(1)
LstWebSites.Items.Add(Safe(x).Username)
'add the passwords.
Safe(x).Password = ar(2)
LstWebSites.Items.Add(Safe(x).Password)
x += 1
Loop
Thank you for your help.