PC Review


Reply
Thread Tools Rate Thread

build a list object from a comma-delimited list

 
 
giant food
Guest
Posts: n/a
 
      30th Mar 2004
I need some input from someone who is more familiar with the .NET
framework classes.

I have a few programming problems where the user passes in a
comma-delimited string of integers (e.g. "2,7,6,23,5"), and I need to
search it repeatedly as I'm looping over a recordset.

My usual method of doing this is to use the Split() function to parse
the string into an array, and then do sequential searches for
particular IDs like this:

for i as integer = lbound(arr) to ubound(arr)
if arr(i) = searchInt then
'int found; do something
end if
next

Is there a better way? I've also tried [Array].BinarySearch, for when
my list is longer. I'd like to use some sort of list object that I
build given the comma-separated list, which I could verify was only a
list of integers (or some other type). Thanks

--Frank
 
Reply With Quote
 
 
 
 
Cor
Guest
Posts: n/a
 
      30th Mar 2004
Hi Frank,

A pity, that you did not use the dataset.

With a dataset, datatable, dataview you could have done someting as

for i as integer = 0 to arr.length-1
dv.rowfilter = "myfield = " & arr(i)
for y as integer = 0 to dv.count
'do something with every field in the selected rows
next
next

But with the recordset I do not know how to make it more efficient.

Cor


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sum if in value in a comma delimited list in one cell Alex Microsoft Excel Worksheet Functions 1 23rd Jul 2004 07:26 PM
Importing comma delimited contact data into a public contact list on Outlook/Exc Tarpon_Zeke Microsoft Outlook VBA Programming 1 22nd Jul 2004 07:42 PM
converting rows to comma delimited list peterswan Microsoft Excel Misc 2 11th May 2004 10:52 PM
Building Comma Delimited List of Symbols TiVoSoFine Microsoft Excel Misc 5 16th Feb 2004 09:57 PM
How To Create A Mailing List in "Comma Delimited" Format? Bright Spark Microsoft Word New Users 4 17th Jan 2004 05:33 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:24 PM.