Okay Ive got a Huge problem something that my current Programming skills will not be able
to fix. Ive got a Program and a text file , this text file gets load into the list box
but that's not the problem. The problem is that when i make the text file it makes a open line and this line gets loaded into the list box and i don't want empty items. But i don't know how to stop this weird action
SO here's code that i use to make text file

Public MySettingfile As String = My.Application.Info.DirectoryPath & "\Process History.MemFreo"
Dim myCoolWriter As New IO.StreamWriter(MySettingfile, True, System.Text.Encoding.Default)
myCoolWriter.WriteLine()
myCoolWriter.Close()

:D So please help a Newbie out :X

Recommended Answers

All 8 Replies

I don't know how you read in your settings file so maybe this gives you an idea:

Dim dummy() As String = New String() {"", "entry 1", "entry 2", Nothing, "entry 3"}
		ListBox1.DataSource = dummy.Where(Function(s) Not String.IsNullOrEmpty(s)).ToArray

I use this

Dim WoofRead = New IO.StreamReader(MySettingfil)
        While (WoofRead.Peek() > -1)
            ListBox2.Items.Add(WoofRead.ReadLine)
        End While
        WoofRead.Close()

then change it to:

Dim WoofRead = New IO.StreamReader(MySettingfil)
        While (WoofRead.Peek() > -1)
        dim currentLine as string = WoofRead.ReadLine
        if string.isnullorempty(currentLine) then continue for
            ListBox2.Items.Add(currentLine)
        End While
        WoofRead.Close()

Im not sure what you mean by this

if string.isnullorempty(currentLine) then continue for

Then continue for ???

sorry had a typo in. so here you go:

Dim WoofRead = New IO.StreamReader(MySettingfil)
		While (WoofRead.Peek() > -1)
			Dim currentLine As String = WoofRead.ReadLine
			If String.IsNullOrEmpty(currentLine) Then 'if line is empty then go to next line
				Continue While
			End If
			ListBox2.Items.Add(currentLine)
		End While
		WoofRead.Close()

:)Thank you GEEK BY CHOICE:P
You saved My life AGIAN :D

;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.