Main Content

Variable Number of Arguments

To create the component for this example, see Variable Number of Arguments. Then create a Microsoft® Visual Basic® application as follows:

  1. Review the sample application for this example in matlabroot\toolbox\dotnetbuilder\Examples\VSVersion\NET\VarArgExample\VarArgVBApp\VarArgApp.vb.

    The program listing is shown here.


    The program does the following:

    • Initializes three arrays (colorSpec, data, and coords) using the MWArray class library

    • Creates a Plotter object

    • Calls the extracoords and drawgraph methods

    • Uses MWNumericArray to handle the data needed by the methods


      For information about these data conversion classes, see the MATLAB MWArray Class Library Reference, available in the matlabroot\help\dotnetbuilder\MWArrayAPI folder, where matlabroot represents your MATLAB® installation folder

    • Uses a try-catch-finally block to catch and handle any exceptions

    The following statements are alternative ways to call the drawgraph method:

    data = CType(plotter.drawgraph(colorSpec, coords(0), coords(1), coords(2), 
           coords(3), coords(4)), MWNumericArray)
    data = CType(plotter.drawgraph(colorSpec, coords), MWNumericArray)
  2. Build the VarArgApp application using Visual Studio® .NET.

    1. The VarArgVBApp folder contains a Visual Studio .NET project file for this example. Open the project in Visual Studio .NET by double-clicking VarArgVBApp.vbproj in Windows® Explorer. You can also open it from the desktop by right-clicking VarArgVBApp.vbproj > Open Outside MATLAB.

    2. Add a reference to the MWArray component, which is matlabroot\toolbox\dotnetbuilder\bin\architecture\framework_version\mwarray.dll.

    3. If necessary, add (or update the location of) a reference to the VarArgComp component which you built in a previous step. (The component, VarArgComp.dll, is in the \VarArgExample\VarArgComp\x86\V2.0\Debug\distrib subfolder of your work area.)

  3. Build and run the application in Visual Studio .NET.