supersuny2k
asked on
Compare two arrays- Find what's missing
Background, I have a text box that is split into an array which contains usernames, these are then search and populate into a list box.
At the end of this I would like to compare the text box array and the list box results and write to another list box to say what usernames could not be found.
How would I do that?
Many Thanks
Josh
At the end of this I would like to compare the text box array and the list box results and write to another list box to say what usernames could not be found.
How would I do that?
Many Thanks
Josh
ASKER
With the text box,
A list of Usernames are place in the multiline text box, and then I use the split function (chr13) to load this into an Array. e.g sGid = Split(txtGid.Text, Chr(13))
Hope that helps
Cheers
Josh
A list of Usernames are place in the multiline text box, and then I use the split function (chr13) to load this into an Array. e.g sGid = Split(txtGid.Text, Chr(13))
Hope that helps
Cheers
Josh
put them both into a stringcollection ...
pesudo code logic ..
foreach foo in textbox
if StringCollection2.Contains foo
its there
else
its not
end if
end for
pesudo code logic ..
foreach foo in textbox
if StringCollection2.Contains
its there
else
its not
end if
end for
Uou can loop through array and compare with the item with the same indes in the listbox
The question is how do you write to the listbox. And if you populate the list box from arrya why do you expect that something will be missing?
The question is how do you write to the listbox. And if you populate the list box from arrya why do you expect that something will be missing?
ASKER
GregoryYoung,
Can you explain more please
Cheers
Josh
Can you explain more please
Cheers
Josh
you have an array which came from the split()
you have an array which represents the ones in the listbox (ones found)
make the array of the ones in the listbox a StringCollection instead of an array and just use
for(i=0;i<SplitString.Leng th;i++) {
if(ListBoxStringCollection .Contains( SplitStrin g[i])) {
//its there
} else {
//its not
}
}
If you put up specific code I can show you more.
Greg
you have an array which represents the ones in the listbox (ones found)
make the array of the ones in the listbox a StringCollection instead of an array and just use
for(i=0;i<SplitString.Leng
if(ListBoxStringCollection
//its there
} else {
//its not
}
}
If you put up specific code I can show you more.
Greg
doh VB.NET sorry I put it in C#
ASKER
Hi Greg
Here is my code for splitting the Text Box
sGid = Split(txtGid.Text, Chr(13))
For l = LBound(sGid) To UBound(sGid)
sGidSearch = Replace(sGid(l), Chr(10), "")
Next
for the List box I am reading the as Selected items, the listbox is MultiExtended
I see what you mean, but am lost on how to make the listbox a StringCollection, to be honest, I have never used that function
Hope this helps thank you
Josh
Here is my code for splitting the Text Box
sGid = Split(txtGid.Text, Chr(13))
For l = LBound(sGid) To UBound(sGid)
sGidSearch = Replace(sGid(l), Chr(10), "")
Next
for the List box I am reading the as Selected items, the listbox is MultiExtended
I see what you mean, but am lost on how to make the listbox a StringCollection, to be honest, I have never used that function
Hope this helps thank you
Josh
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Perfect Thank you
> I have a text box that is split into an array which contains usernames
Not clear.
What do you mean by "split into an array"??
Maybe you can give a concrete example?
Dabas