Products & Services Solutions Academia Support User Community Company

Learn more about MATLAB Builder NE   

Magic Square Example (Visual Basic)

To create the component for this example, see the first several steps in Deploying a Component Using the Magic Square Example. After you build the MagicSquareComp component, you can build an application that accesses the component as follows.

  1. For this example, the application is MagicSquareApp.vb.

    You can find MagicSquareApp.vb in:

    matlabroot\toolbox\dotnetbuilder\Examples\VS8\NET
      \MagicSquareExample\MagicSquareVBApp

    The program listing is as follows.

     MagicSquareApp.vb

    The application you build from this source file does the following:

    • Lets you pass a dimension for the magic square from the command line.

    • Converts the dimension argument to a MATLAB integer scalar value.

    • Declares variables of type MWNumericArray to handle data required by the encapsulated makesquare function.

    • Creates an instance of the MagicSquare class named magic.

    • Calls the makesquare method, which belongs to the magic object. The makesquare method generates the magic square using the MATLAB magic function.

    • Displays the array elements on the command line.

  2. Build the application using Visual Studio .NET.

    1. The MagicSquareVBApp folder contains a Visual Studio .NET project file for each example. Open the project in Visual Studio .NET for this example by double-clicking MagicSquareVBApp.vbproj in Windows Explorer.

    2. If necessary, add a reference to the MWArray component, which is matlabroot\dotnetbuilder\bin\architecture\framework_version
      \mwarray.dll.

    3. If necessary, add a reference to the MagicSquareComp component, which is in the distrib subfolder.

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

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS