📄 frmvbolemat.frm
字号:
VERSION 5.00
Begin VB.Form frmVBOLEMat
Caption = "在VB与MATLAB之间OLE时传输矩阵数据"
ClientHeight = 4305
ClientLeft = 60
ClientTop = 345
ClientWidth = 10965
LinkTopic = "Form1"
ScaleHeight = 4305
ScaleWidth = 10965
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton cmdExit
Caption = "关 闭"
Height = 375
Left = 8520
TabIndex = 13
Top = 3480
Width = 1935
End
Begin VB.CommandButton cmdCompute
Caption = "求原矩阵的逆矩阵"
Height = 375
Left = 6000
TabIndex = 12
Top = 3480
Width = 1935
End
Begin VB.Frame Frame1
Caption = "原矩阵"
Height = 2655
Left = 240
TabIndex = 0
Top = 360
Width = 4575
Begin VB.TextBox txtEle
Height = 375
Index = 5
Left = 3240
TabIndex = 9
Text = "5"
Top = 1200
Width = 975
End
Begin VB.TextBox txtEle
Height = 375
Index = 8
Left = 3240
TabIndex = 8
Text = "0"
Top = 1920
Width = 975
End
Begin VB.TextBox txtEle
Height = 375
Index = 7
Left = 1800
TabIndex = 7
Text = "2"
Top = 1920
Width = 975
End
Begin VB.TextBox txtEle
Height = 375
Index = 6
Left = 360
TabIndex = 6
Text = "7"
Top = 1920
Width = 975
End
Begin VB.TextBox txtEle
Height = 375
Index = 4
Left = 1800
TabIndex = 5
Text = "2"
Top = 1200
Width = 975
End
Begin VB.TextBox txtEle
Height = 375
Index = 3
Left = 360
TabIndex = 4
Text = "4"
Top = 1200
Width = 975
End
Begin VB.TextBox txtEle
Height = 375
Index = 2
Left = 3240
TabIndex = 3
Text = "9"
Top = 480
Width = 975
End
Begin VB.TextBox txtEle
Height = 375
Index = 1
Left = 1800
TabIndex = 2
Text = "3"
Top = 480
Width = 975
End
Begin VB.TextBox txtEle
Height = 375
Index = 0
Left = 360
TabIndex = 1
Text = "1"
Top = 480
Width = 975
End
End
Begin VB.Label lblOut
Height = 1575
Left = 5040
TabIndex = 11
Top = 1080
Width = 5655
End
Begin VB.Label Label1
Caption = "逆矩阵"
Height = 255
Left = 5160
TabIndex = 10
Top = 600
Width = 2775
End
End
Attribute VB_Name = "frmVBOLEMat"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cmdCompute_Click()
Dim objMATLAB As Object
Dim dblInReal(1 To 3, 1 To 3) As Double
Dim dblInImag(1 To 3, 1 To 3) As Double
Dim dblOutReal(1 To 3, 1 To 3) As Double
Dim dblOutImag(1 To 3, 1 To 3) As Double
Dim i As Integer
Dim j As Integer
dblInReal(1, 1) = Val(txtEle(0).Text)
dblInReal(1, 2) = Val(txtEle(1).Text)
dblInReal(1, 3) = Val(txtEle(2).Text)
dblInReal(2, 1) = Val(txtEle(3).Text)
dblInReal(2, 2) = Val(txtEle(4).Text)
dblInReal(2, 3) = Val(txtEle(5).Text)
dblInReal(3, 1) = Val(txtEle(6).Text)
dblInReal(3, 2) = Val(txtEle(7).Text)
dblInReal(3, 3) = Val(txtEle(8).Text)
For i = 1 To 3
For j = 1 To 3
dblInImag(i, j) = 0
Next
Next
Set MatLab = CreateObject("matlab.application")
Call MatLab.PutFullMatrix("InM", "base", dblInReal, dblInImag)
Call MatLab.Execute("OutM=inv(InM);")
Call MatLab.GetFullMatrix("OutM", "base", dblOutReal, dblOutImag)
Dim strOutM As String
lblOut.Caption = ""
For i = 1 To 3
For j = 1 To 3
strOutM = strOutM & dblOutReal(i, j) & Chr(9)
Next
lblOut.Caption = lblOut.Caption & strOutM & Chr(13) & Chr(10)
strOutM = ""
Next
Set MatLab = Nothing
End Sub
Private Sub cmdExit_Click()
Unload frmVBOLEMat
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -