Visual Basic help needed!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • More Booze
    Confirmed User
    • Mar 2004
    • 5116

    #1

    Visual Basic help needed!

    Code:
    Open "c:\stuff\content.txt" For Input As #1
       Do
    
            Input #1, texten
            If texten <> "" Then
                
                List1.AddItem texten
            End If
        Loop Until EOF(1)
        
    Close #1
    The problem is that each time the textline contains a comma "," it adds a new line to the listbox. I tried to fix it with this code.

    Code:
    texten = Replace(texten, Chr(44), "hahaha44")  <-- (special HTML chr for comma.)
    But it doesn't work. How do I solve this?
  • More Booze
    Confirmed User
    • Mar 2004
    • 5116

    #2
    *bump*****

    Comment

    • SilverTab
      Confirmed User
      • Nov 2001
      • 5060

      #3
      huh weird! I wonder why a coma is causing a new line??

      BTW im not that familiar with vb but is:
      Input #1, texten

      the same as

      Line Input #1, texten???

      Line input should grab all the text untill it meets a linefeed...so coma shoulnt be a prob?... I dunno...
      mmm my sig was too big... no more cool animation
      but hey still! need php? ICQ: 94586959

      Comment

      • More Booze
        Confirmed User
        • Mar 2004
        • 5116

        #4
        Hey! I just changed it to
        Line Input #1, texten
        and it worked! Thanks! :-)

        Comment

        • SilverTab
          Confirmed User
          • Nov 2001
          • 5060

          #5
          no prob


          glad I could help ;)
          mmm my sig was too big... no more cool animation
          but hey still! need php? ICQ: 94586959

          Comment

          • Myst
            Confirmed User
            • Feb 2004
            • 4708

            #6
            Private Sub LoadContents(Lst As Object, sPath As String)
            Dim iFN As Integer
            Dim sEntry As String
            Lst.Clear 'clear the list
            iFN = FreeFile ' get a free filenumber
            Open sPath For Input As iFN ' open the file
            Do Until EOF(iFN) ' loop until end of file (EOF) reached
            Line Input #iFN, sEntry ' get the next entry
            Lst.AddItem sEntry ' add entry to the list
            Loop
            Close iFN ' close the file
            End Sub
            ICQ: 298-523-037

            Comment

            Working...