how would you do this.

G

Guest

hey all,

i have my ideas on how i can do this but i just want to get different
perspective.

i have a string that contains comma-separated values.
(a,b,c)
i want to create a string that looks like the following
('a' and 'b' and 'c')

how would you do this?

the way i'm thinking is like this

Dim ary As Array
ary = Split(value, ",")
For Each item As String In ary
sb.Append(Chr(39))
sb.Append(item)
sb.Append(Chr(39))
sb.Append(" AND ")
Next

but my problem is how to get rid of the trailing AND?

thanks,
rodchar
 
S

Siva M

This is another way:

Dim s As String = "aa,bb,cc,dd"
s = "'" & s.Replace (",", "' and '") & "'"
' s now has 'aa' and 'bb' and 'cc' and 'dd'

hey all,

i have my ideas on how i can do this but i just want to get different
perspective.

i have a string that contains comma-separated values.
(a,b,c)
i want to create a string that looks like the following
('a' and 'b' and 'c')

how would you do this?

the way i'm thinking is like this

Dim ary As Array
ary = Split(value, ",")
For Each item As String In ary
sb.Append(Chr(39))
sb.Append(item)
sb.Append(Chr(39))
sb.Append(" AND ")
Next

but my problem is how to get rid of the trailing AND?

thanks,
rodchar
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,278
Latest member
BuzzDefenderpro

Latest Threads

Top