⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 magicdemoapp.vb

📁 matlab实用教程
💻 VB
字号:
' *******************************************************************************'' MagicDemoApp.vb'' This file is an example for using MATLAB COM component inside .NET Visual ' Basic application.'' Copyright 2001-2006 The MathWorks, Inc.'' *******************************************************************************Imports SystemImports MagicDemoCompNamespace MathWorks.Demo.MagicDemoApp    ' <summary>    ' The MagicDemoApp class computes a magic square of the user specified size.      ' </summary>    ' <remarks>    ' args[0] - a positive integer representing the array size.    ' </remarks>    Class MagicDemoApp#Region " MAIN "        ' <summary>        ' The main entry point for the application.        ' </summary>        Shared Sub Main(ByVal args() As String)            Dim arraySize As Integer            Dim magic As MagicSquareClass = Nothing            Try                ' Get user specified command line arguments or set default                If (0 <> args.Length) Then                    arraySize = System.Int32.Parse(args(0))                Else                    arraySize = 4                End If                ' Create the magic square object                magic = New MagicSquareClass                ' Compute the magic square and print the result                Dim nativeArray As Object = New Object                magic.makesquare(1, nativeArray, arraySize)                ' Convert the magic square array to a two dimensional native double array                Console.WriteLine("{0}Magic square as native array:{1}", Chr(10), Chr(10))                If (nativeArray.GetType().IsArray) Then                    Dim myArray As System.Array = CType(nativeArray, System.Array)                    ' Display the array elements:                    For i As Integer = myArray.GetLowerBound(0) To myArray.GetUpperBound(0)                        For j As Integer = myArray.GetLowerBound(1) To myArray.GetUpperBound(1)                            Console.WriteLine("Element({0},{1})= {2}", i, j, myArray.GetValue(i, j))                        Next j                    Next i                End If                Console.ReadLine()  ' Wait for user to exit application            Catch exception As System.Runtime.InteropServices.COMException                Console.WriteLine("COM Error: {0}", exception)            Catch exception As Exception                Console.WriteLine("Error: {0}", exception)            Finally                ' Free the COM object                If Not (magic Is Nothing) Then                    System.Runtime.InteropServices.Marshal.ReleaseComObject(magic)                End If            End Try        End Sub#End Region    End ClassEnd Namespace

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -