Results 1 to 3 of 3

Thread: [RESOLVED] [2005] A strange error in streamwriter

  1. #1

    Thread Starter
    Addicted Member Genom's Avatar
    Join Date
    May 2006
    Posts
    186

    Resolved [RESOLVED] [2005] A strange error in streamwriter

    Code:
        Private Sub frmProducts_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
    
            Dim i As Integer, Str As String = ""
    
            Dim file As System.IO.StreamWriter
    
    
            For i = 0 To lsbProducts.Items.Count - 1
    
                Str = Str & lsbProducts.Items.Item(i).ToString & vbCrLf
    
            Next
    
            file = My.Computer.FileSystem.OpenTextFileWriter(AppPath & "\Ürünler.txt", True)
            file.Write(Str)
            file.Close()
    
    
            Me.Close()
        End Sub
    It was the code. It tries to write to a textfile which is on a memory stick. but the problem is it writes and doesnt stop. ıt writes same thing again and again...

    Where is the problem?
    Dim Me As Coder

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] A strange error in streamwriter

    The FormClosed event is raised when the form is closed. Why the call to Me.Close? Do you suppose that that's causing the FormClosed event to be raised over and over?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Addicted Member Genom's Avatar
    Join Date
    May 2006
    Posts
    186

    Re: [2005] A strange error in streamwriter

    yes thanks again jmcilhinney...
    Dim Me As Coder

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width