How to read a delimetered line of strings and ints and extract them for processing
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: How to read a delimetered line of strings and ints and extract them for processing

Hybrid View

  1. #1
    Join Date
    Aug 2009
    Posts
    10

    Talking 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.

  2. #2
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008
    Location
    WV
    Posts
    4,830

    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.

  3. #3
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    14,982

    Re: How to read a delimetered line of strings and ints and extract them for processin

    And, it's DELIMITED
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  4. #4
    Join Date
    Dec 2008
    Location
    Step Into(F11)
    Posts
    465

    Smile 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
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center