need help with listbox

If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
6 posts Page 1 of 1
Contributors
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

need help with listbox
Dummy1912
hello,

who can help us with this weird small problem
it seems after been removed from listbox
and listbox will be empty it keeps going with checking

the point is when the listbox is empty it need to stop
because when everything has been deleted why do he keep checking it?

what did we forgot?
Code: Select all
            Dim file(ListBox2.Items.Count - 1) As String 
            For i = 0 To ListBox2.Items.Count - 1
                file(i) = ListBox2.Items(i).ToString()
            Next

            For x = 0 To file.Length - 1
                checkme()
                Me.Cursor = Cursors.Default
                If sended Then
                    ListBox2.Items.RemoveAt(0)
                    Application.DoEvents()
                End If

            Next
thank you.
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
User avatar
clanc789
Coding Guru
Coding Guru
Posts: 786
Joined: Tue Nov 02, 2010 4:45 pm

Re: need help with listbox
clanc789
What is 'checkme()' for function?
Practice makes perfect!

VIP since: 6-10-2011
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

Re: need help with listbox
Dummy1912
#clanc789
don't worry about the checkme() part
its the for x that has troubles :)
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
User avatar
XTechVB
VIP - Site Partner
VIP - Site Partner
Posts: 727
Joined: Thu May 20, 2010 10:32 am

Re: need help with listbox
XTechVB
well i forgot a lot about vb programming but it seems to me that this is the problem
Code: Select all
            For x = 0 To file.Length - 1
                checkme()
                Me.Cursor = Cursors.Default
                If sended Then
                    ListBox2.Items.RemoveAt(0)
                    Application.DoEvents()
                End If

            Next
Why don't you put that in a IF statement that checks if there are items in the listbox, if so runs the loop.
You can find me on Facebook or on Skype mihai_92b
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

Re: need help with listbox
Dummy1912
#XTechVB

i have that part already but doesn't do anything about it
it still continues.
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
User avatar
comathi
Coding God
Coding God
Posts: 1242
Joined: Fri Mar 26, 2010 1:59 pm

Re: need help with listbox
comathi
You remove the items from the ListBox, but you don't remove them from the array.

Could that be why it still checks even though the ListBox is empty?
6 posts Page 1 of 1
Return to “Coding Help & Support”