1

I have limited VB Script experience, but have been working on the script below and keep getting errors, the most common being "expected identifier".

Can someone tell me what I'm missing here?

Dim class as Integer
if [AGE_DATABA] >= 200 AND [Riparian_S] <> 1 then
class = 5
elseif [AGE_DATABA] > 200 AND [Riparian_S] = 1 then
class = 2
else
class = 0
End if

expression = class

1

I think there are two things going on. First, you can't use "class" as a variable name, since VBScript reserves that for defining classes. And second omit the "as Integer" in your declaration.

This should work:

Dim rip_class
if [AGE_DATABA] >= 200 AND [Riparian_S] <> 1 then
rip_class = 5
elseif [AGE_DATABA] > 200 AND [Riparian_S] = 1 then
rip_class = 2
else
rip_class = 0
End if
  • Ah, rookie mistake with 'class' as a variable name. Thank you. – barnyanka Jan 27 '15 at 18:19
1

Your code does not work because you are using the reserved keyword in VB which is class.

Dim n
if [AGE_DATABA] >= 200 AND [Riparian_S] <> 1 then
    n = 5
elseif [AGE_DATABA] > 200 AND [Riparian_S] = 1 then
    n = 2
else
    n = 0
End if

your field = n

1

I dug up the following article from microsoft about the error you are getting.

https://msdn.microsoft.com/en-us/library/5e3hfkby(v=vs.84).aspx

It seems there is an issue with either the syntax or using a VB specific work as a variable.

I think the word "class" is a reserved word in VB Script.

http://support.microsoft.com/kb/216528

Try changing "class" to something totally different and running again.

Good Luck!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.