By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,168 Members | 2,548 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,168 IT Pros & Developers. It's quick & easy.

Separating text from .txt into colums in listview (VB.net mobile)

P: 1
Hey guys.

I want to separate each text into their own Column in VB.net.

How do I achieve this?

Screenshot:



Each entree is seperated with "|" . My Code:

Expand|Select|Wrap|Line Numbers
  1. Private Sub MenuItem3_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem3.Click
  2. Dim folder As String = Environment.GetFolderPath(Environment.SpecialFolder.Personal)
  3. Using sw As StreamWriter = File.AppendText("\My Expenses.txt")
  4.  
  5. sw.WriteLine(DateTimePicker.Text + Space(1) & "|" & Subject.Text + Space(4) & "|" & Category.Text + Space(5) & "|" & Amount.Text + Space(4) & "|" & Peyment.Text)
  6. sw.Close()
  7. End Using
  8. End Sub
  9.  
Apr 15 '12 #1
Share this Question
Share on Google+
1 Reply


MrMancunian
Expert 100+
P: 569
Basically, you need to find out how the text is in the text-file. If it's line by line, you just start reading lines till EOF (End of File) and split each line on the character "|". You put them all in an multidimensional array so it looks like this:

Expand|Select|Wrap|Line Numbers
  1. [0][Date]
  2. [0][Subject]
  3. [0][Category]
  4. [0][Amount]
  5. [0][Payment]
  6. [1][Date]
  7. [1][Subject]
  8. [1][Category]
  9. [1][Amount]
  10. [1][Payment]
The first column in your array is the line, the second contains the values you read from your textfile.

After that, it's just a matter of inserting your array in your table.
Apr 18 '12 #2

Post your reply

Sign in to post your reply or Sign up for a free account.