Listbox owerflow problem when list-items are numbers
listbox always overflows which has more than thousands of items, i need a way to get rid of this.. I need to use an alternate object which can act as listbox!
Private Sub difference_Click()
'Find differences and show'
j = 0
For i = 0 To secretlist1.ListCount - 1
'If i use 2nd "for" with J it would cause to get same items again and again!
'for that reason im not gonna do that instead im using a definition for j as long
'but it keeps overflow problem so icant use it either.
If Val(secretlist2.List(i)) <> Val(secretlist1.List(j)) Then
lostonelist.Visible = True 'show the lostonelist
lostonelist.AddItem secretlist1.List(j) 'add the items which are not in list2
i = i - 1 'if they r not equal to each other move list2 index to previous one
End If
j = j + 1
'we moved list2 index to previous cause list1 index always will be increasing
'and when they r not equal to eachother we must make sure that next item in list1
'will be compared with the same item in list2
Next
End Sub
OR an easier way to do it with Do While:
Private Sub difference_Click()
'Find differences and show'
j = 0
i = 0
'For i = 0 To secretlist1.ListCount - 1
Do While Not secretlist1.ListCount - 1
If Val(secretlist2.List(i)) <> Val(secretlist1.List(j)) Then
lostonelist.Visible = True
lostonelist.AddItem secretlist1.List(j)
i = i - 1
End If
开发者_Go百科 j = j + 1
i = i + 1
Loop
End Sub
What i am trying is searching the items that is not in secretlist2 while they remains in secretlist1.. Also in these listboxes all my items are numbers no string in any of them.. But "secretlist1(j)" always overflows i need a way to get rid of this.. and i have thousans of list items. i need another object which i can use as listbox, im still searching for a solution i think this is a good example and when i found an answer to it before u can find.. ill post it here. Ty already.
Important Note: This is a Visualbasic 6 project not a .NET project!
i was making this example for teaching my little brother how to! but i overflow my self while doing it "facepalm" xD
Consider adding the ability to "page" thru' your data. Many records is beyond being usable to a person.
Use paging and some well-thought-out search routines rather than tossing all the data at the user and praying for results.
many rows will take time no matter what you're doing.
suggest change your desing
other, use apis that for example is for seek in listbox
L = SendMessage(cList.hwnd, LB_FINDSTRINGEXACT, -1, ByVal sText)
populate with windows directory
SendMessage List1.hwnd, LB_DIR, DDL_READWRITE, "*.asp"
=== Other Option index your items how
private m_indexData as collection
private sub loadInfo()
dim rs as adodb.recordset
rs = IProductRepository.GetAll()
PopulateIndex indexData, rs
End sub
private sub PopulateIndex(byref indexdata as collection, rs as adodb.recorset)
.....
end sub
class itemselected 'that is conceptual class for indexdata
key as string
description as strin
location as location
end class
enum location
[user list A]
[user list B]
[secret list C]
end enum
'//now user actions
public sub FindDiferences()
dim subcollection as collection
subcollection = filtercollection(indexdata, [sectet list c])
end sub
public function filterCollection (data as collection, location as location) as Collection
....
end function
精彩评论