//flex table opened by JP

Click to See Complete Forum and Search --> : help with vbscript code


csamuels
03-21-2005, 09:46 AM
i got this code to check if a user set only one of three values. With this code as is i get Line:18 Col:0 Expected 'End' Syntax Error:. I think its telling me to change my first else to a end if. when i change all my else's to end if's then i get the following error Line:18 Col:4 Expected 'Function' Syntax Error:.

i=0

if SEND_TO = NC then
i=i+1
end if

if UW_USERID = NC then
i=i+1
end if

if GOTO_AUTH = NC then
i=i+1
end if

if i = 0 then GETTRUEFALSE = FALSE
else
if i < 2 then GETTRUEFALSE = TRUE
else
if i = 3 then GETTRUEFALSE = FALSE
end if

ScaryBinary
03-21-2005, 11:56 AM
In their infinite wisdom, Microsoft decided that "Else If" should really be one word, as in "ElseIf". So, your If statements should read something like
If i = 0 Then
GETTRUEFALSE = FALSE
ElseIf i < 2 Then
GETTRUEFALSE = TRUE
ElseIf i = 3 Then
GETTRUEFALSE = FALSE
End If

The official MS documentation for the If...Then...Else VBScript statement is here (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/vtoriStatements.asp).

You might also want to look into the Select...Case statements, documented here (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/vtoriStatements.asp). Sometimes they work a little better than If...Then...Else.