+ Reply to Thread
Results 1 to 3 of 3

Thread: VBScripting problem

  1. #1
    Steve Richards
    Join Date
    Apr 2012
    Posts
    10
    Points
    0
    Answers Provided
    0


    0

    Default VBScripting problem

    Hello,

    I am in the process of moving over to ArcGIS 10.0 and my old scripts are not working in VBscript. Over the long-run I will be learning Python and converting all my scripts to that language. However, right now I just need to get this one script to run using VBscript. I have very little scripting experience and any help in getting this code to work in VBscript would be most appreciated. Thank-you! The following error is produce when it tries to run the calculate field tool in the model:

    General error executing calculator.
    ERROR 999999: Error executing function.
    Sub or Function not defined
    Failed to execute (Calculate Field (4))


    CODE:
    dim strA

    if [STATUS] = " " then
    if [LOGYEAR] <> " " and [FEATURE] like "WTP*" then
    strA = [STATUS]
    elseif [LOGYEAR] = " " then
    strA = "CP"
    else
    strA = "NSR"
    end if
    elseif [STATUS] = " " and [LOGYEAR] = " " then
    strA = "CP"
    else
    strA = [STATUS]
    end if
    Click image for larger version

Name:	PIONEER_Monthly.PNG
Views:	41
Size:	73.6 KB
ID:	14072

  2. #2
    Curtis Price

    Join Date
    Oct 2009
    Posts
    1,810
    Points
    875
    Answers Provided
    127


    0

    Default Re: VBScripting problem - Like operator

    Quote Originally Posted by 66stever View Post

    Expression: strA
    Code:
    dim strA
    
    if [STATUS] = " " then
      if [LOGYEAR] <> " " and [FEATURE] like "WTP*" then
        strA = [STATUS]
      elseif [LOGYEAR] = " " then
        strA = "CP"
      else
        strA = "NSR"
      end if
    elseif [STATUS] = " " and [LOGYEAR] = " " then
      strA = "CP"
    else
      strA = [STATUS]
    end if
    I believe "Like" is SQL, not VBScript.

    You may have better luck with:

    Code:
    Left([FEATURE],3) = "WTP"
    PS Please use [code] tags when posting code.
    Last edited by curtvprice; 05-04-2012 at 02:24 PM.

  3. #3
    Steve Richards
    Join Date
    Apr 2012
    Posts
    10
    Points
    0
    Answers Provided
    0


    0

    Default Re: VBScripting problem

    Hi Curtis,

    Thank you for your help. It worked great!

    Take care,

    Steve

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts