我在這里寫了一個矩陣計算的類 但是每次運行都顯示定義有問題 不知道各位老哥能不能幫我看看

把前面的代碼都附上 謝謝各位老哥'操作矩陣的類 Matrix
Option Explicit
Const eps As Double = 0.00000001 '預設精度
Dim nRows As Double '矩陣行數
Dim nCols As Integer '矩陣列數
Dim elements() As Double
Public Sub init(ByVal r As Integer, ByVal c As Integer)
'指定行列構造矩陣,r表示行,c表示列
nRows = r
nCols = c
ReDim elements(r * c - 1)
End Sub
Public Property Let Element(ByVal r As Integer, ByVal c As Integer, _
ByVal value As Double)
'設定指定元素的值,r表示行,c表示列
elements(c + r * nCols) = value
End Property
Public Property Get Element(ByVal r As Integer, ByVal c As Integer) As Double
'獲取指定元素的值,r表示行,c表示列
Element = elements(c + r * nCols)
End Property
Public Sub initUnit(ByVal n As Integer)
'將方陣初始化為單位矩陣
Dim i As Integer, j As Integer
init n, n
ReDim elements(n * n)
For i = 0 To 0 - 1
For j = 0 To 0 - 1
Element(i, j) = 1
Next j
Next i
End Sub
Public Property Get numRows() As Integer
'獲取矩陣的行數
numRows = nRows
End Property
Public Property Get numCols() As Integer
'獲取矩陣的列數
numCols = nCols
End Property
Public Sub setValue(other As Matrix)
'給矩陣賦值
Dim i As Integer, j As Integer
init other.numRows, other.numCols
For i = 0 To other.numCols - 1
For j = 0 To other.numRows - 1
Element(i, j) = other.Element(i, j)
Next j
Next i
End Sub
uj5u.com熱心網友回復:
other as objectuj5u.com熱心網友回復:
感謝回復 我試一試!uj5u.com熱心網友回復:
說明你沒有定義“Matrix”這個型別轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/30203.html
標籤:VB基礎類
下一篇:VB程式合并
