Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

MenuStrip Save is not saving the text inside the listbox

$
0
0
I have information in a listbox and when I click save, I am able to select the destination and title of the text file. Once I open the text document it is blank. Here is my code for the MenuStrip Save.
[Private Sub mnuSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuSave.Click
        'Does the current document have a filename?
        If strFileName = String.Empty Then
            'Use the Save as dialog to save the document
            If sfdSaveFile.ShowDialog() = Windows.Forms.DialogResult.OK Then
                strFileName = sfdSaveFile.FileName
                SaveDocument()
            End If
        Else
            'Save the document with the current file
            sfdSaveFile.ShowDialog()
        End If
    End Sub]

Here is the code for the sfdSaveFile:

[Private Sub sfdSaveFile_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles sfdSaveFile.FileOk
        Dim FileToSave As String = sfdSaveFile.FileName

        Dim objwriter As New System.IO.StreamWriter(FileToSave)
        objwriter.Write(lstAccountInfo.Text)
        objwriter.Close()
    End Sub
End Class]

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>