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

Getting Streamwriter to export filtered results to a .txt file

$
0
0
Hello,
I have a question about using the StreamWriter function in VB 2010.
Is it possible to filter the results of a list box by their first letter (i.e - in my case the first letter of separate countries) when exporting to a .txt file using the Streamwriter function? I am using a combo box as a drop down list to select the letter to filter out. Basically, I need to figure out how to filter a long list of Countries based on the letter selected by the user then export it using streamwriter. Here is my code so far, however this doesn't filter any results, just writes them all in the .txt file, what can i do to make the code get filtered by first letter obtained from a drop down list box?

    Private Sub btnExport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExport.Click
        fbdExport.ShowDialog()
        Dim swrExportStream As StreamWriter = New StreamWriter(fbdExport.SelectedPath)
        Dim intCDCLocations As Integer

        intCDCLocations = lstCDCLocations.Items.Count - 1
        For intIndex As Integer = 0 To intCDCLocations
            swrExportStream.WriteLine(lstCDCLocations.Items(intIndex))
        Next intIndex
        swrExportStream.Close()

    End Sub


Viewing all articles
Browse latest Browse all 51036

Trending Articles



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