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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

extreacting name-value pairs from an array of querystrings 1

Status
Not open for further replies.

cm80

Technical User
May 3, 2001
85
US
Hi,
I have an array of querystrings from which I want to extract the separate name value pairs.

For example I have a number of querystrings like the one below and I want to be able to loop through and extract each of the 'Fund' and 'asp' values in the array

deviceid=B5B0C9-249E-1100000-9B91-00902787507C&zipcode=unknown&Fund=BAL&asp=modules/abc/default.asp

Does anyone have any idea where I could start please.
 
You can use the instr() function to find the location of Fund and then keep track of locations and use mid() or right() to grab the values you need.
ex.
myString = "zipcode=unknown&Fund=BAL&asp=modules"
start = instr(1,myString,"Fund") + 5
'because Fund= is 5 characters
'This gives you the starting location of BAL
'in this case, 22
end = instr(start,myString,"&")
'This gives you the location of the & after BAL
'in this case, 25
strFund = mid(myString, start, end-start)
'strFund is now "BAL"

I've used instr, mid, right and left to do all kinds of string parsing.
Basically I use instr to find the starting and ending points of the sections I need to grab, then use mid with the length set to end minus start.
Hope this helps,
Shanti
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top