Hello...a colleague of mine done a function in VBScript but the
function gives an error:

<%

function test_String(st)
l1 = len(st)
teste = true

if l1 >20 then
teste = false
end if

if InStr(st, "script", 1)>0 then
teste = false
end if

test_String = teste

end function

%>


Microsoft VBScript compilation error '800a03ea'

Syntax error

/menu_lateral2.asp, line 3

function test_String(st)
^


Can anyone help me? i dont understand about VBScript and the website
is done because of this...

Re: Function error by McKirahan

McKirahan
Wed Jul 02 06:01:00 CDT 2008

"Pépê" <josemariabarros@gmail.com> wrote in message
news:01f62f72-1450-433b-a335-afa00d63dff5@p25g2000hsf.googlegroups.com...
> Hello...a colleague of mine done a function in VBScript but the
> function gives an error:
>
> <%
>
> function test_String(st)
> l1 = len(st)
> teste = true
>
> if l1 >20 then
> teste = false
> end if
>
> if InStr(st, "script", 1)>0 then
> teste = false
> end if
>
> test_String = teste
>
> end function
>
> %>
>
>
> Microsoft VBScript compilation error '800a03ea'
>
> Syntax error
>
> /menu_lateral2.asp, line 3
>
> function test_String(st)
> ^
>
>
> Can anyone help me? i dont understand about VBScript and the website
> is done because of this...

To quickly test it I converted it to a VBS file:

WScript.Echo test_String("st")
'<%
function test_String(st)
l1 = len(st)
teste = true
if l1 >20 then
teste = false
end if
if InStr(st, "script", 1)>0 then
teste = false
end if
test_String = teste
end function
'%>

A "Type mismatch" error was displayed.

The cause was you use of InStr():

The InStr function syntax has these arguments:
start (Optional), string1, string2, compare (Optional)

start -- The start argument is equired if compare is specified.
compare -- If omitted, a binary comparison is performed.

Change
if InStr(st, "script", 1)>0 then
to
if InStr(1, st, "script", 1)>0 then