Question about VB Script

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Question about VB Script

    Hi, friends:

    I have a question here.

    I test some script codes, but error information called " an OLE object doesn't have an default value" happened.

    Please see attached files.

    STARTUP =ALIGNMENT/START,RECALL:, LIST= YES
    ALIGNMENT/END
    MODE/DCC
    LOADPROBE/D2L50E100
    TIP/T1A0B0, SHANKIJK=0, 0, 1, ANGLE=0
    FORMAT/TEXT,OPTIONS, ,HEADINGS,SYMBOLS, ;NOM,TOL,MEAS,DEV,OUTTOL, ,
    C1 =COMMENT/INPUT,NO,'Please type an Integer '
    COMMENT/OPER,NO,beore script variable is V1
    ,
    ASSIGN/V1 = INT(C1.INPUT)
    CS1 =SCRIPT/FILENAME= C:\SCRIPT1.BAS
    FUNCTION/Main,SHOW=YES,,
    STARTSCRIPT/

    VB script file:

    Sub Main
    Dim App As Object
    Set App = CreateObject ("PCDLRN.Application")
    Dim Part As Object
    Set Part = App.ActivePartProgram
    Dim Var As Object

    Set Var = Part.GetVariableValue ("V1")
    msgbox Var
    Dim I As Object
    If Not Var Is Nothing Then
    Var.longvalue = Var.longvalue + 1
    Part.SetVariableValue "V1", Var
    MsgBox Var
    Else
    Msgbox "Could Not find variable"
    End If
    End Sub


    It seems value of "V1" can't give to VB script V1.

    Can somebody help me out?

    version is PCDMIS 3.7

    Thanks!

    yingying

  • #2
    Hi yingying,

    It looks like you're following the example about modifying variables using scripting in the help file. It seems there is a problem with the example. If you change your MsgBox line to read:

    MsgBox Var.LongValue

    It should work.

    For example, here's my version of the script (named Test2.bas) that works:

    Sub Main
    Dim App As Object
    Set App = CreateObject ("PCDLRN.Application")
    Dim Part As Object
    Set Part = App.ActivePartProgram
    Dim Var As Object
    Set Var = Part.GetVariableValue ("V1")
    Dim I As Object
    If Not Var Is Nothing Then
    Var.LongValue = Var.LongValue + 1
    Part.SetVariableValue "V1", Var
    MsgBox "V1 is now: " & Var.LongValue
    Else
    Msgbox "Could Not find variable"
    End If
    End Sub

    And here's my part program code:

    C1 =COMMENT/INPUT,NO,'Please type an integer value'
    ASSIGN/V1 = INT(C1.INPUT)
    COMMENT/OPER,NO,Variable V1's value before script is:
    ,V1
    CS1 =SCRIPT/FILENAME= D:\TEMP\TEST2.BAS
    FUNCTION/Main,SHOW=YES,,
    STARTSCRIPT/
    ENDSCRIPT/
    COMMENT/OPER,NO,Variable V1's value after script is:
    ,V1
    Jared Hess - Techwriter @ WAI
    [View 2008 Reporting Tutorials Here]

    Comment


    • #3
      Jared:

      You are right. Thanks for your help.

      yingying

      Comment

      Related Topics

      Collapse

      Working...
      X