I have a question about converting text file elements to arrays in VB. I am generally not a .Net programmer, and have really basic question about parsing array elements in VB.
I have a text file that is formatted as the following...
What I would like to do is open this file and add the Items into an array element so that the array is formatted as a String Array
... and so on...
I have used some coding examples that I found earlier...
Private Sub OpenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenToolStripMenuItem.Click Dim strFileName As String OpenFileDialog1.Title = "Open Text File" OpenFileDialog1.Filter = "Text Files|*.txt" Dim DidWork As Integer = OpenFileDialog1.ShowDialog() If DidWork = DialogResult.Cancel Then MsgBox("Cancled") Else strFileName = OpenFileDialog1.FileName 'Dim tempString As String = IO.File.ReadAllLines(strFileName) Dim tempString As String = IO.File.ReadAllText(strFileName) Dim x As Integer = tempString.Length - 1 '//Array Size Integer Dim itemArray(x) As String '//Array that the text file is stored into. Dim i As Integer = 0 '//Counter Integer For Each myChar As Char In tempString itemArray(i) = myChar i += 1 Next MsgBox(strFileName + " Opened Sucessfully") RichTextBox1.Lines = itemArray End If
Which parses the array elements of each character onto a single line, but as you can see I am searching for a string element per line to be contained in the file. I am not sure how to make that happen in VB. Also you will notice that the text file is , delimited in between the quote's which is also causing me some trouble.
Oh yes, and one more question. What is the difference between the