5 Replies Latest reply on Mar 16, 2011 9:14 PM by Ahmad Fattahi

    VBA syntax for scaling a trend

    cjrancur

      I found that I can scale a trend using either of these commands within a "with myTrend" block:

       

      .SetTraceScale "Autorange", "Autorange"

       

      or

       

      Call .SetTraceScale("Autorange","Autorange")

       

      What is the difference between a space followed by parameters, and  parameters within parentheses?  Is one syntax version better than the other for ProcBook use?

       

      I tried to use a VT_Variant instead of the string, "Autorange", but VT_Variant was not available.  Which reference should be added to enable VT_Variant objects?

       

      Also, I tried using the second statement, where the parameters were within parenthesis, but without the leading Call statement, and it did not work.  I don't understand why. For example, there is a difference between the two statements below. The first works and the second doesn't. Why?

       

      Call .SetTraceScale("Autorange","Autorange") 

       

      and

       

      .SetTraceScale("Autorange","Autorange") 

       

      Carrie

        • Re: VBA syntax for scaling a trend
          Ahmad Fattahi

          Sub procedures can be called in one of two ways. First, you can use the Call statement, like this:

           

           Call DoSomething(sSomeString, isomeInteger)

           

          If you use the Call statement, you must enclose the argument list in parentheses. The other method of calling a sub is by simply using its name, but if you don't use the Call statement, don't put parentheses around the argument list:

           

           DoSomething sSomeString, iSomeInteger

           

          If you aren't going to use the return value of a function, you can use either of the above methods to call the function. Otherwise, use the function name as part of an expression. For example:

           

           If GetItNow(sSomeStuff) = 10 Then

           

          Like the Call statement, when you use a function call as part of an expression, the argument list must be enclosed within parentheses.