-
July 1st, 2010, 12:30 PM
#1
How to read a delimetered line of strings and ints and extract them for processing
Hi, I have the following text file (ExamMarks.txt)
John, 85, 95, 90
Micheal, 60, 75, 75
I want to extract a line and take the Name and separately and the ints separately. Then I want to print the name and the average of the numbers like this in a label:
John's average is 90
Micheal's average is 70
So far I can only display what is in the text file in a label (see below):
|Dim FILE_NAME As String = "C:\ExamMarks.txt"
| Dim TextLine As String
|
| If System.IO.File.Exists(FILE_NAME) = True Then
|
| Dim objReader As New System.IO.StreamReader(FILE_NAME)
|
| Do While objReader.Peek() <> -1
| TextLine = TextLine & objReader.ReadLine & vbNewLine
|
| Loop
|
| lblResults.Text = TextLine
|
| Else
|
| MsgBox("File Does Not Exist")
|
| End If
Any help is appreciated.
-
July 1st, 2010, 02:01 PM
#2
Re: How to read a delimetered line of strings and ints and extract them for processin
You would use .Split() to put the elements of the string into a string array using the comma as the delimiter.
btw.. when looking for help with VB.Net you should..
1: Post in the VB.Net area of the forum
2: Tell us what version you are using.
This area is for questions regaurding VB6
Always use [code][/code] tags when posting code.
-
July 1st, 2010, 08:08 PM
#3
Re: How to read a delimetered line of strings and ints and extract them for processin
-
July 2nd, 2010, 11:46 PM
#4
Re: How to read a delimetered line of strings and ints and extract them for processin
Please read the forum rules first. [code]your code here and close as well .
Last edited by firoz.raj; July 2nd, 2010 at 11:50 PM.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|