Visual Basic Array text file

346 views Asked by At

I'm trying to attach a text file with my data for an array Visual Basic, in Visual Studio 2012.

How do you deliminate new values in the array? I've tried new lines, commas, quotes and it still reads it all as

arrayname(0)

2

There are 2 answers

0
aric8456 On BEST ANSWER

I figured it out

 Dim Arrayname() As type = My.Resources.ResourceName.Split(Environment.NewLine)
0
Alex On

You probably need a split() function. How is the text file organized? Are all the values separated by newlines?

Dim arrayname() As String
Dim text_string As String

text_string = "whatever you need to import from text file"
arrayname() = Split(text_string, " ") 'example splitting using spaces

output:

arrayname(0) = "whatever"

arrayname(1) = "you"

...