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!

Error: Invalid procedure call or argument 'Mid'

Status
Not open for further replies.

cm80

Technical User
May 3, 2001
85
US
Hi,
I am getting the following error and can't figure out why,

Microsoft VBScript runtime error '800a0005'

Invalid procedure call or argument: 'Mid'

/fido/admin/regSessionReport.asp, line 168



Here is the function which is causing the error and line 168 is highlighted in bold.
If anyone can figure it out I would really appreciate it, Thank you


####################################################

Function getValue(Querystring, Name)

Dim strQueryString, strName, valueStart, valueEnd, strValue
strQueryString = Querystring
strName = Name

'get the starting location 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 of the value

strValue = Mid(strQueryString, valueStart, valueEnd - valueStart)

GetValue = strValue
End Function
 
It is tough to tell w/out seeing an example of what Querystring and Name contain, but you are sending some value to mid in valuestart or valueend-valuestart. You are probably sending a negative number or some other invalid parameter.

Try stepping through your code and watching the value of these variables.

what happens when the name is not in the string?

This may be bad logic or just a need to catch certain situations that will give you incorrect parameters for the call to mid.

 
You are awful trusting. I do not see any verification that either Instr returned a 0 because it could not find the search string. That is where the Mid is going wrong, I think.
Code:
valueStart = InStr(1, strQueryString, strName) + (Len(strName) + 1)
'get the location of the '&' after the value
valueEnd = InStr(valueStart, strQueryString, "&")
'get the value of the value
if ValueStart > 0 and valueEnd > 0 then
    strValue = Mid(strQueryString, valueStart, valueEnd -   valueStart)
End if

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top