Showing results 1 to 3 of 3

Thread: Vba run function with parameter for susbtitution

  1. #1
    Join Date

    Default VBA- Run function with parameter for substitution


    In ComboBox I have 16 variables from 1 to 16, each one execute the same function (screen switch) but with diferent parameter for substitution. Everything is ok and works if I'm doing it manually by clicking, but if I want to make a macro where I will run this function, the parameter for substitution is not working.

    Public Sub LeftClickUp_tracking(obElem As Element)
    Dim nr As Integer
    nr = obElem.ItemVariable(0).Value
    If nr > 0 And nr < 17 Then
    thisProject.RtFunctions.Item("Trolley[" & nr & "]").Start <- set value to combobox variable
    thisProject.RtFunctions.Item("Vehicles").Start <-open screen
    thisProject.RtFunctions.Item("Trolley_Control").DynProperties("PictSwitch.SubstiVar[" & nr & "]") <- not working here
    thisProject.RtFunctions.Item("Trolley_Control").Start <- open screen "control panel" with configured buttons for substi

    Any idea how to get access and choose a good one substitution parameter from VBA?
    Thank you in advance !

  2. #2
    Join Date
    Salzburg, AT

    Default Re: Vba run function with parameter for susbtitution

    In the screen switch function you are using the parameter for substitution - {PARAM}, but the use of the indexing variable - {X01}, would make the solution easier. I've written already in previous tread:
    You can evaluate in Logic (or VBA if you prefer more risky solutions) the "Position[1..119]" variables to the vehicle number and then use this number as indexing variable (X01) in screen switch function on tab 'Replace indices'.
    The use of PARAM is resonable when vehicals are dynamically moving symbols, the indexing variable - when you keep the concept to change dynamically which symbol is for which vehicle.

    I'm attaching a screenshot from similar attempt. In my project there are 5 feeders with 5 buttons linked with the same function to open the same detail screen. The number of feeder to focus (Feeder_1 .. Feeder_5) is in variable FeederName. Similarly, if you prefer VBA: you can link a VBA macro with LeftClickDown event of button. In macro you can evaluate the Position to get the vehicle reference; the vehicle reference is indexing variable. 

    do not forget to call the original event handler - e.g. obElem.LeftClickDown - before the end of Sub:
    End Sub
    Attached Thumbnails Attached Thumbnails Replace_indices.png  

  3. #3
    Join Date

    Frage Re: Vba run function with parameter for susbtitution

    Is it possible to access "Parameter for substitution" string in runtime via API?

    I've tried to access this in PreFunctionExecute or in DynPictureOpen,  but both w/o success.


Similar Threads

  1. bsLibName parameter of Symbols.Export function
    By stolyarov_as in forum VSTA
    Replies: 2
    Last Post: 25th March 2014, 08:51
  2. Call VBA function from another project
    By abcd1234 in forum VBA
    Replies: 1
    Last Post: 6th November 2013, 23:31
  3. Execute function in VBA
    By focus in forum VBA
    Replies: 1
    Last Post: 17th January 2012, 15:17
  4. Replies: 1
    Last Post: 11th June 2009, 08:02
  5. Replies: 4
    Last Post: 29th September 2008, 10:44

Tags for this Thread

Posting Rules

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