Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how to replace value with another in string (url)

0 views
Skip to first unread message

Stephane Viau

unread,
Jul 3, 2002, 9:32:19 AM7/3/02
to
i have the following url being passed as the linkback page during
authentication

map.asp?gt=R&gc=21&L=1&T=RR&pw=muskoka&map=1&cid=1212312&sid=333455


the problem is that i need to append sid and cid parameters to url, but its
possible that those already exist in original url. how can i replace
specific values with others

for example, if cid or sid exist then replace its values with new ones
cid=12312312 replaced cid=9999999


thanks
stephane


Eph0nk

unread,
Jul 3, 2002, 10:10:13 AM7/3/02
to
Make a copy of the querystring, as a NameValueCollection. Remove the cid &
sid, replace it with the new values.
Check .Net documentation for more info on the NameValueCollection and how to
use it.

---
Tim De Vogel
S-Data NV

"Stephane Viau" <sv...@crea.ca> schreef in bericht
news:eDfSdXpICHA.3924@tkmsftngp10...

alex bowers

unread,
Jul 3, 2002, 10:16:37 AM7/3/02
to
Hi Stephane

I assume you're using a code page here.
Put the url (or the querystring) into a string variable
and use the string.IndexOf function to determine whether
cid or sid exist, and append if necessary.

Alex

>.
>

Stephane Viau

unread,
Jul 3, 2002, 10:17:34 AM7/3/02
to
ok, but at that point its only a string. does querystring work with this?

thanks
stephane

"Eph0nk" <tim.antispam...@s-data.be> wrote in message
news:3d23061b$0$8145$ba62...@news.skynet.be...

Eph0nk

unread,
Jul 3, 2002, 11:04:38 AM7/3/02
to
No, QueryString is not a string but a read-only NameValueCollection, so you
must copy the Querystring to another NameValueCollection (that isn't
read-only), in order to replace the values. The url & "?" &
newnamevaluecollection = new href

---
Tim De Vogel
S-Data NV

"Stephane Viau" <sv...@crea.ca> schreef in bericht

news:uUgpvwpICHA.2212@tkmsftngp12...

Jim Buyens

unread,
Jul 3, 2002, 2:30:12 PM7/3/02
to
"Stephane Viau" <sv...@crea.ca> wrote in message news:<eDfSdXpICHA.3924@tkmsftngp10>...

I would find the beginning of the query string by using instr to find
the question mark, then split the query string into an array.

intPos = instr(strURL,"?")
strQSparms = split(mid(strURL,strPos+1),"&")

then, you can loop through the array looking for sid and cid

for intPos = 0 to UBound(strQSparms)
...
loop

if you find sid= or cid=, in lcase(left(strQSparms(intPos),4))
then replace them and set an indicator. Then, confert the array back
to a string, as in

strNewQstring = Join(strQSParms,"&")

then, if you failed to find sid=, append it to strNewQstring. Same for
cid.

Jim Buyens
buy...@interlacken.com
Author of:
*------------------------------------------------------*
|\----------------------------------------------------/|
|| Web Database Development Step by Step .NET Edition ||
|| ||
|| From Microsoft Press ||
|/----------------------------------------------------\|
*------------------------------------------------------*

0 new messages