I need to display Label w/ 2 fields' values like that [_PID] & "/" & [_NAME]. Its VBScript looks like that below:
[_PID] & "/" & [_NAME]
But if [_PID] == [_NAME], I only need to display [_PID]. I tried the VBScript below:
Function FindLabel ( [_PID] )
dim newString as string
newString = ""
if [_PID] == [_NAME] then
newString = [_PID]
else
newString = [_PID] & "/" & [_NAME]
end if
However, I receive error: "Carriage returns are not allowed in simple expressions".
How this problem can be fixed? Thanks if you can help.
Changed to
Function FindLabel ( [_PID], [_NAME] )
if [_PID] <> [_NAME] then
FindLabel = [_PID] & "/" & [_NAME]
else
FindLabel = [_PID]
end if
end function
Then it works. Thanks for your review.
In VBScript, you'll always get an error if you instantiate a variable as a specific object like this:
dim newString as string
You have to just do that like this:
dim newString