It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming Visual Basic Forum

[vb2005] Formatting Listbox output when saving to a file

Moderator: dafunkymunky

[vb2005] Formatting Listbox output when saving to a file

Postby craigl on Sat Jun 30, 2007 3:50 pm

Seems simple enough, but there is a twist.........here is the scenario:-

Within the app the user is initially presented with a series of check boxes. Depending on the number of checkboxes selected the number of items in the list box varies. In the example data below two check boxes are selected hence three lines in each "block" as the two items are associated with the master hence three items in each "block". So in my list box I have the following :-

item1 'master item 1
item2 'associated item (checkbox 1)
item3 'associated item (checkbox 2)
------
item4 'master item 2
item5 'associated item (checkbox 1)
item6 'associated item (checkbox 2)
------
etc

The dotted lines are in the listbox contents as a visual device to seperate the master & subitem "blocks". My goal is to obtain the following output :-

item1,item2,item3
item4,item5,item6
etc
etc

Using variations of this code :-

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim i As Integer
w = New IO.StreamWriter("c:\test.txt")
For i = 0 To ListBox1.Items.Count - 1
w.Write(ListBox1.Items.Item(i) & ",")
Next
w.Close()
End Sub

I get :-

Item1,item2,item3,item4,item5,item6,

or

item1,
item2,
item3,
item4,
item5,
item6,

I can't seem to get the output format to provide what I am looking for. Any assistance would be gratefully appreciated.
craigl
 
Posts: 0
Joined: Sat Jun 30, 2007 3:45 pm

Postby dafunkymunky on Sat Jul 07, 2007 6:34 pm

within the for loop why don't you check every time for the ------ line and when it is encountered give new line command.. btw who is generating the lines.. you or the computer it self..
--------DAFUNKYMUNKY--------
::THE::NECESSARY::[D]EVIL::
....errr i mean munky....
User avatar
dafunkymunky
100+ Club
 
Posts: 183
Joined: Fri Apr 08, 2005 7:32 am
Location: India


Who is online

Users browsing this forum: No registered users and 5 guests