I'm trying to put the items in positions of an array, but I get the error that the variable is outside the bounds of the array. I do not know how to fix the bug and I need help.
Follow the code:
Dim posicao As String = String.Join("", itens)
Dim separa As String()
Dim contagem As String
contagem = ListBox1.Items.Count
Dim i As Integer
For i = 0 To contagem
separa = Split(posicao, ";")
cpf = separa(0)
nome = separa(1) 'O erro ocorre aqui.
anonasc = separa(2)
Next
TextBox1.Items.Add(cpf & ";" & nome & ";" & anonasc)
The program does not point me to code errors. I'm parsing the items variable, which gets the lines of a .txt file.
The file_file variable receives the .FileName from an OpenFileDialog.
Variable itens
:
Dim local_arquivo As String
itens = (My.Computer.FileSystem.ReadAllText(local_arquivo, System.Text.Encoding.Default)).Replace(vbLf, String.Empty).Split((CChar(vbCr)))
ListBox1.Items.AddRange(itens)