Click to See Complete Forum and Search --> : String manipulation


Terry
04-09-2003, 05:52 PM
I have an updateable ASP form that returns data from a database. One of the
fields - an input box - contains names. Sometimes this box will contain multiple
names separated by a comma i.e. "Doe, John, Mitnick, Kevin, Gates, Bill".
All the names get returned in one long string on the same line. I would
like to return each name on its own line within some type of form element
- textarea, listbox etc. All the names are held in one field in my table.
So I need to insert a & vbCLf after every other comma. I'm really stuck
and I have a bad tendency to over think these things sometimes. Can anyone
offer a hint on how they might approach this problem?

Thanks

js
04-09-2003, 06:00 PM
you could do something like the following

<%
mystring = "test1,test2,test3"
myarray = split(mystring,",")
for x=0 to ubound(myarray)
response.Write "some formatting - " & myarray(x) & " - more formatting<br>"
next
%>



"Terry" <snakbrat@yahoo.com> wrote:
>
>I have an updateable ASP form that returns data from a database. One of
the
>fields - an input box - contains names. Sometimes this box will contain
multiple
>names separated by a comma i.e. "Doe, John, Mitnick, Kevin, Gates, Bill".
> All the names get returned in one long string on the same line. I would
>like to return each name on its own line within some type of form element
>- textarea, listbox etc. All the names are held in one field in my table.
> So I need to insert a & vbCLf after every other comma. I'm really stuck
>and I have a bad tendency to over think these things sometimes. Can anyone
>offer a hint on how they might approach this problem?
>
>Thanks
>

Terry
04-10-2003, 10:48 AM
Hey js thanks a lot!

I have everything working properly now but not as I originally intended.


The users populate the name field in my data_table from a dropdown on an
asp form which is pulled from another name_table that is set up as lastname
comma firstname. So when multiple names are selected the string on the update
asp form would return

lastname1 comma firstname1 comma lastname2 comma firstname2 comma lastname3
comma firstname3 etc.

I was having real difficulty trying to split my string at the second comma.
I ended up just removing all the commas from the name_table. Now all the
names in the name_table are just lastname firstname - which isn't that big
of a deal.

Now that I've slept on it - I see a few other ways I could have tackled the
problem.. like adding an id column to the name_table and storing that value
in the data_table.

Thanks again I was really stumped!



"js" <test@test.com> wrote:
>
>you could do something like the following
>
><%
>mystring = "test1,test2,test3"
>myarray = split(mystring,",")
>for x=0 to ubound(myarray)
> response.Write "some formatting - " & myarray(x) & " - more formatting<br>"
>next
>%>
>
>
>
>"Terry" <snakbrat@yahoo.com> wrote:
>>
>>I have an updateable ASP form that returns data from a database. One of
>the
>>fields - an input box - contains names. Sometimes this box will contain
>multiple
>>names separated by a comma i.e. "Doe, John, Mitnick, Kevin, Gates, Bill".
>> All the names get returned in one long string on the same line. I would
>>like to return each name on its own line within some type of form element
>>- textarea, listbox etc. All the names are held in one field in my table.
>> So I need to insert a & vbCLf after every other comma. I'm really stuck
>>and I have a bad tendency to over think these things sometimes. Can anyone
>>offer a hint on how they might approach this problem?
>>
>>Thanks
>>
>