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

please take a look, small mistake but can't find solution

Status
Not open for further replies.

cm80

Technical User
May 3, 2001
85
US
Could someone please take a look at this code. I think I have a small mistake somewhere but I am not sure where:

Function:
Function GetValue(Querystring, Name)
'Querystrings are broken up into a series of name value pairs.
'The purpose of this function is to return a value corresponding to the name passed as a parameter
Dim strQueryString, strName, valueStart, valueEnd, strValue
strQueryString = QueryString
strName = Name

'starting position of the value
valueStart = InStr(1, strQuerystring, strName)+Len((strName) + 1)
'get the location of the '&' after the Value
valueEnd = InStr(valueStart, strQuerystring, "&")
'get the value
strValue = Mid(strQuerystring, valueStart, valueEnd - valueStart)

GetValue = strValue
End Function

Querystring:
deviceid=0.2268606658.587869489&zipcode=00000&Fund=FFTN&asp=modules/OH/default.asp

If I pass 'Fund' as the name parameter what I expect:
FFTN

What I am actually getting:
eviceid=0.2268606658.587869489


I think I may have the wrong syntax for using the Len statement but I have tried it loads of different ways and can't figure it out.
Any help would be appreciated,
Thank You
 
Try:
Function:
Function GetValue(Querystring, Name)
'Querystrings are broken up into a series of name value pairs.
'The purpose of this function is to return a value corresponding to the name passed as a parameter
Dim strQueryString, strName, valueStart, valueEnd, strValue
strQueryString = QueryString
strName = Name

'starting position of the value
valueStart = InStr(1, strQuerystring, strName)+Len(strName)+ 1
'get the location of the '&' after the Value
valueEnd = InStr(valueStart, strQuerystring, "&")
'get the value
strValue = Mid(strQuerystring, valueStart, valueEnd - valueStart)

GetValue = strValue
End Function

Also you need to account for the last parameter in which there will not be a trailing &. You need to check if ValueEnd is 0. One Question, why are you writing this instead of just using the Request object? Wushutwist
 
Thanks anyway, but I figured it out myself.
The problem was the way I was passing the parameters. I never put the Name parameter in ""
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top