'下面直接写好两个函数,以供在使用符合变量求解一些问题时[非线性方程组求解,积分,多元非线性拟合……],使用程序默认求解就会导致程序卡死,解决这种问题的方法即是先动态编译函数,然后在函数内部直接读入需要辅助计算的数据,这个时候就可以完全解决程序卡死现象。也因此,在这里简单写了一个从文件读入、写入数据的函数,到时直接复制粘贴进主函数即可.注意下面数据存储的格式是,对于矩阵[m*n],则分别有m行,每一行的数据以逗号分隔

Public Function DataRead(ByRef FilePath As String) As Double(,)
        Dim K(0, 0) As Double
        If My.Computer.FileSystem.FileExists(FilePath) Then
            Dim Str, ArryM(0), ArryN(0) As String
            Dim reg As New System.Text.RegularExpressions.Regex("[;\n]{2,}")
            Dim i, j, m, n As Integer
            Try
                Str = My.Computer.FileSystem.ReadAllText(FilePath, System.Text.Encoding.Default)
                Str = reg.Replace(Str, ";").Replace(" ", "")
                If Str.StartsWith(";") Then
                    Str = Mid(Str, 2, Str.Length - 1)
                End If
                If Str.EndsWith(";") Then
                    Str = Mid(Str, 1, Str.Length - 1)
                End If
                ArryM = Str.Split(";")
                ArryN = ArryM(0).Split(",")
                m = ArryM.Length - 1
                n = ArryN.Length - 1
                ReDim K(m, n)
                For i = 0 To m
                    ArryN = ArryM(i).Split(",")
                    For j = 0 To n
                        K(i, j) = CDbl(ArryN(j))
                    Next
                Next
                Return K
            Catch ex As Exception
                Return Nothing
            End Try
        Else
            Return Nothing
        End If
    End Function
    Public Function DataWrite(ByRef FilePath As String, ByRef Data(,) As Double) As Boolean
        Dim i, j, m, n, k As Integer
        Dim str As String = ""
        m = Data.GetLength(0)
        n = Data.Length \ m - 1
        n -= 1
        k = 0
        Try
            For i = 0 To m
                For j = 0 To n - 1
                    str += Data(i, j).ToString + ","
                    k += 1
                    If k > 4096 Then
                        System.IO.File.AppendAllText(FilePath, str)
                        k = 0
                        str = ""
                    End If
                Next
                str += Data(i, n).ToString
                If i < m Then
                    str += vbCrLf
                End If
            Next
            System.IO.File.AppendAllText(FilePath, str)
        Catch ex As Exception
            Return False
        End Try
        Return True
    End Function