VBA errors

Hello

How can find the exact source of VBA errors? I am using one of the faceplate and when open the faceplate show error (error number 9 (9)). too many links in faceplate and I can not follow the error. how can see the error handler scripts?

Thanks

  • Hi MOH

    The real error message for error #9 is "Subscript out of range" and mean that an array of data have been dimensionned with a too small number of items.
    Look at your code where this kind of variable are used.
    They look like this : Variable(123)

    If you expect to stop the error handling, you can try this :
    When the faceplate is open in Operate configure mode, goto to the Workspace menu + User preferences.
    On the "Environment Protection" tab, uncheck the "Disable VBE Access"
    +
    Open the Visual Basic editor
    Open the Tools+Option menu
    On the "General" tab, choose the "Break on All Errors" option button.
    +
    Save your faceplate file + close

    Then, run Operate and open your Faceplate.
    The script may stop on the error : you will know in witch procedure it happens.

    Good luck
    NB : Don't make modification of the script in run mode : will not be able to save it.
  • In reply to Jack_France:

    Hi Jack
    Thanks I Will Check it.
    Regards
  • In reply to MOH:

    Hi
    I use DeltaV faceplate, and follow Jack procedure, the code break on highlighted line. please if you find the error help me
    Tanks


    Private Sub CFixPicture_LoadedTagGroup(ByVal bstrTagGroupName As String)

    On Error GoTo ErrorHandler
    RepIndicator.TimerEnabled = False
    frszDvsysIAInit Me
    frszSetASCContext Me, ps_nm.CurrentValue

    ps_mode_nma = ps_nm.CurrentValue & "/dc1/mode"
    ps_sp_d_nma = ps_nm.CurrentValue & "/dc1/sp_d.a_cv"
    ps_accept_d_nma = ps_nm.CurrentValue & "/dc1/accept_d.f_cv"

    pb_Script_Done.CurrentValue = False
    Dim strOpsel As String
    Dim strSelections() As String
    Dim strOpselNMA As String
    pn_num_selections.CurrentValue = 0
    strOpselNMA = ps_nm.CurrentValue + "/dc1/sp_d.a_opsel"
    strOpsel = frsreadvalue(strOpselNMA)
    strSelections = Split(strOpsel, ",")
    +++++ ps_passive.CurrentValue = strSelections(0) ++++++ERROR line
    ps_active_1.CurrentValue = strSelections(1)
    If UBound(strSelections) > 1 Then
    ps_active_2.CurrentValue = strSelections(2)
    End If
    pn_num_selections.CurrentValue = UBound(strSelections) + 1
    If TGCounter > 0 Then
    'we need to indicate that the module has been changed.
    Dim oTag As Object
    If frsObjexists("ChgIndicator", Me, oTag) Then
    oTag.Visible = True
    ps_SavedCaption.CurrentValue = frsGetCaption(Me)
    frsSetCaption Me, strNewModuleInFP
    End If
    'set and start the timer
    RepIndicator.StartTime = DateAdd("s", 4, Time)
    RepIndicator.TimerEnabled = True
    RepIndicator.StartTimer
    End If
    TGCounter = TGCounter + 1
    pb_Script_Done.CurrentValue = True

    Exit Sub
    ErrorHandler:
    frsHandleError
    End Sub
  • In reply to MOH:

    Hi Moh

    It looks like standard code.

    Is there a DC block named DC1 into your module ?
    (If not, I think the error could happen before your error line)

    Is a NameSet have been defined on the SP_D parameter of this DC1 block ?

    The instruction, that generate the error, read the first named state of the NameSet associated with SP_D.
    Normaly, this first name state exists (and the second one too).
    So, I think the problem is in the module, not in this code.
  • In reply to Jack_France:

    HI Jack
    I checked the SP_D parameters, in some module did not return any values (indication modules(without any command)) ,and i saw errors only in these modules. i think i need to checked SP_D parameters and if is null jump these lines.
    Thanks & regards
  • In reply to MOH:

    No SP_D nameset assigment ?
    What a strange idea.
    Or do you mean that the reading code doesn't work, sometime ?
    Strange too, because a frsReadValue that cannot succeed generate an error the error handle may intercept.
  • In reply to Jack_France:

    Hi
    Nameset is assigned to sp but ,as i checked in some of module (serial Module that use for indication and can not send commands) the "dc1/sp_d.a_opsel" did not return any values. I think the source of error is this parameter.
  • In reply to MOH:

    Hi,For this line : strOpselNMA = ps_nm.CurrentValue + "/dc1/sp_d.a_opsel"
    Are you sure that "+" is the correct character ?Could you replace it by "&"
    And for debug, you can also use a mgsbox ?Regards
  • In reply to Richard Dubois:

    Hi
    I used data link and monitor this parameter in display (modulename/dc1/sp_d.a_opsel) but did not show anyting
  • In reply to MOH:

    Check that the nameset you are using for this SP_D parameter has values that have the User Selectable Check box checked

  • In reply to Matt Stoner:

    I check it, for this type is not user selectable
  • In reply to MOH:

    I has to be User Selectable for it work from the FP