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

Mid

Status
Not open for further replies.

FranckM

Programmer
May 8, 2002
76
CA
This is the error I get when I try using mid:

Error Type:
Microsoft VBScript runtime (0x800A0005)
Invalid procedure call or argument: 'Mid'
/ESD-PSE/language.asp, line 4

This is the code I have that results in this error:

sString = Request.ServerVariables("HTTP_REFERER")
sExt = Mid (sString, Instr (sString, ".html"))

I have no idea what's wrong. If anyone can see what the problem, I would greatly appriciate the help. Thanks for reading and replying ;)
 
mid has got the following prototype:

mid(Stringtouse,startposition,number of characters to return)

for instance:

sString = Request.ServerVariables("HTTP_REFERER")
sExt = Mid (sString, (Instr (sString, ".html")),4)

 
If the Referer page does not contain the string ".html" then the InStr function will return a null value which in turn will cause an error in your Mid function.

You need to first check the result of your InStr before applying this to your Mid function

for example...
Code:
sString = Request.ServerVariables("HTTP_REFERER")
intValue = Instr(sString, ".html")

If intValue <> 0 Then
  sExt = Mid(sString, intValue)
End If
Tony
reddot.gif WIDTH=400 HEIGHT=2 VSPACE=3

 
Yes, that's the problem fester, the referer is an asp page..
Thanks for the help, gonna be looking into that and see how I can work my way around the red ribbon...eheh
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top