0
votes
Public Function BinarySearch(userNameString, switchPosition) As Boolean
    If Right(LCase(userNameString), 8) = "lastname" Then
        If Left(LCase(userNameString), 5) = "admin" Or Left(LCase(userNameString, 7) = "firstname" Then
            If StrComp(switchIsOn(switchPosition), "1", vbTextCompare) = 0 Then
                ' Verify the user is admin lastname or firstname lastname and switch is on
                Return True
            Else
                ' Verify the user is admin lastname or firstname lastname and switch is off
                Return False
            End If
        Else
            ' Users last name is lastname
            Return False
        End If
    Else
        ' Not lastname
        Return False
    End If    
End Function

When I run it, I get an error on the first line Public Function...

What I get is "Microsoft VBScript compilation error: Expected statement"

2

2 Answers

1
votes

You cannot type in VBScript so:

Public Function BinarySearch(userNameString, switchPosition) As Boolean

0
votes

In vbscript everything is variant , no need to type your variables. Assingng your return value to the name of your function: BinarySearch = false You name your function binarysearch and then you do a textcompare ?