Problem with reading txt file
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 6 of 6

Thread: Problem with reading txt file

  1. #1
    Join Date
    Sep 2009

    Problem with reading txt file

    i have a problem when I read from a txt file.
    I looks something like this:

    And now when I put the data into strings, the values are:

    Why does it stop at the " , " ?
    I don't wan't it to stop at the ","

  2. #2
    Join Date
    Jan 2006
    Fox Lake, IL

    Re: Problem with reading txt file

    Because , is a field-delimiter in VB6, not a decimal separator.

    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!

  3. #3
    Join Date
    Sep 2009

    Re: Problem with reading txt file

    Ok, but I have now solved the problem, I changed , to .
    But there is a new problem now, if the number is below 1 ex: 0.9
    Then it only shows 9.
    How do I solve this problem?

  4. #4
    Join Date
    Dec 2007

    Re: Problem with reading txt file

    We're not mind readers... if you post the code you are using we may be able to help.

    * I don't respond to private requests for help. It's not conducive to the general learning of others.-I also subscribe to all threads I participate, so there's no need to pm when there's an update.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help - how to remove eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to???
    * On Error Resume Next is error ignoring, not error handling(tm). * Use Offensive Programming, not Defensive Programming.
    "There is a major problem with your code, and VB wants to tell you what it is.. but you have decided to put your fingers in your ears and shout 'I'm not listening!'" - si_the_geek on using OERN
    MVP '06-'10

  5. #5
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008

    Re: Problem with reading txt file

    instead of using input to get the data use line input that will read the entire line and not break at the comma
    Always use [code][/code] tags when posting code.

  6. #6
    Join Date
    May 2010

    Thumbs up Re: Problem with reading txt file


    I don't know how you are reading text file.
    But try this one.


    Option Explicit

    Private Sub Form_Load()
    Call ReadFormFile("C:\Test.txt")
    End Sub

    Rem Read data from file using Sequentila file handling
    Public Function ReadFormFile(strFilePath As String) As Boolean
    Dim tempString As String

    Rem Open text file
    Open strFilePath For Input As #1

    Rem Read line by line
    While EOF(1) = 0
    Line Input #1, tempString
    MsgBox tempString

    Rem Close text file
    Close #1
    End Function


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 survey!

HTML5 Development Center