Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with string functions

Status
Not open for further replies.

jpack23

Programmer
Dec 15, 2004
82
US
I have a field from a datagrid that contains employee id separated by a comma for example

2,3,22

or

22,3
or

2,3

or
2,44,104

any combination of single double or triple digits separated with a comma

What I need to do is separte each of those ids one at a time and run it through a process

code would look something like this for the string "2,44,104'

Dim intI as integer
dim intID as integer

Dim IntNumber as integer = string function to get number of commas + 1 (this would get the number of IDs as 3)

do while intI less or equal to IntNumber
intID = String function to get IntI number
do stuff with intID
intI +1
next


the first pass throught the loop IntID = 2
second pass through the loop IntID = 44
third pass through the loop IntID = 104


the number of ID is that original string vary and each ID may be 1 2 or 3 characters in length.


Thanks for you help



 



hi,

Check out the Split function.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
for each s as string in split(value, ",")
' do some work
next

=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
CCNA, CCDA, MCSA, CNA, Net+, A+, CHDP
VB.NET Programmer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top