Welcome to APLNext Sign in | Join | Help
in
Community Website
Blogs Forums

Late question on the VSTO - Excel - Visual APL screen cast.

Last post 04-20-2007, 2:56 AM by Ajay.Askoolum. 1 replies.
Sort Posts: Previous
  • Late question on the VSTO - Excel - Visual APL screen cast.

     04-19-2007, 4:12 PM

    We have finally got the right combinations of VSTO, Office and Visual APL and I have gone back through Jairo’s screen cast “Control Microsoft Excel with Visual APL and VSTO” posted 3/22/07. 

     

    My recreation of the demo went well but I have a little question. . .   In the C# project Jairo included a ToDouble method to convert the object[,] value   from the Excel range “ProductData” to  
    double[,] res.

     

    In the ToDouble method there is a double loop for
        (int  i = 0;  i < iRows;  i++)   and   (int  j = 0;  j < iCols;  i++) 

     

    When i and j are used to index the  double[,] res  the default index origin []IO = 0 is used.

    When i and j are used to index the  object[,] value  the index origin seem to be 1 because we used  (double)value[i+1, j+1].

     

    What’s going on, why does get res indexed as res[ i , j ] and value as value[ i + 1, j + 1] ??

  • Re: Late question on the VSTO - Excel - Visual APL screen cast.

     04-20-2007, 2:56 AM

    An observation :

    The default index origin in Excel (Option Base) is 1 which I think explains the indexing in index origin 1.
     
    Option Base is an optional setting in VBA for VBA code, default setting 1. Some care is required with this as it is not quite universal. For instance,
     
    Option Base 1
    dim a as variant
    a=split("Mon,Tue",",")
    debug,print a(1)
     
    will return Tue and not Mon because arrays created using Split are always based on index 0 regardless of option base setting. In order to coerce a into option base 1, ReDim Preserve is required.
View as RSS news feed in XML
Powered by Community Server, by Telligent Systems