哪位VB高手帮小弟搞一下矩阵运算代码,把界面的设计控件带上!

哪位VB高手帮小弟搞一下矩阵运算代码,把界面的设计控件带上!可以在线HI我!!... 哪位VB高手帮小弟搞一下矩阵运算代码,把界面的设计控件带上!
可以在线HI 我!!
展开
 我来答
注册时吓一跳
2009-09-25 · TA获得超过474个赞
知道小有建树答主
回答量:86
采纳率:0%
帮助的人:0
展开全部
form1 通用
Dim a() As Long
Dim b() As Long
Dim c() As Long
Dim m As Long
Dim n As Long
Dim p As Long
Dim q As Long
Dim flag As Long

Private Sub Command1_Click()
On Error GoTo lab:

m = InputBox("请输入A矩阵行数", "提示")
n = InputBox("请输入A矩阵列数", "提示")
Picture1.Cls
Picture3.Cls
ReDim a(1 To m, 1 To n) As Long
For i = 1 To m
For j = 1 To n
a(i, j) = InputBox("请输入矩阵a(" & i & "," & j & ")数值", "提示")
Picture1.Print a(i, j);
Next j
Picture1.Print
Next i

lab:

End Sub

Private Sub Command2_Click()
On Error GoTo lab:

p = InputBox("请输入B矩阵行数", "提示")
q = InputBox("请输入B矩阵列数", "提示")
Picture2.Cls
Picture3.Cls
ReDim b(1 To p, 1 To q) As Long
For i = 1 To p
For j = 1 To q
b(i, j) = InputBox("请输入矩阵b(" & i & "," & j & ")数值", "提示")
Picture2.Print b(i, j);
Next j
Picture2.Print
Next i

lab:

End Sub

Private Sub Command3_Click()

Picture3.Cls

If m = 0 Or n = 0 Or p = 0 Or q = 0 Then
MsgBox "请先输入矩阵", vbOKOnly, "提示"
GoTo lab:

End If

If m <> p Or n <> q Then
MsgBox "请输入行数和列数相同的矩阵才可相蔽携加", vbOKOnly, "提示"
End If

If m = p And n = q Then
Label1.Caption = "+"
ReDim c(1 To m, 1 To n) As Long
For i = 1 To m
For j = 1 To n
c(i, j) = a(i, j) + b(i, j)
Picture3.Print c(i, j);
Next j
Picture3.Print
Next i
End If
lab:
End Sub

Private Sub Command4_Click()

Picture3.Cls

If m = 0 Or n = 0 Or p = 0 Or q = 0 Then
MsgBox "请先输罩并拆入矩阵", vbOKOnly, "提物枣示"
GoTo lab:
End If

If m <> p Or n <> q Then
MsgBox "请输入行数和列数相同的矩阵才可相减", vbOKOnly, "提示"
End If

If m = p And n = q Then
Label1.Caption = "-"
ReDim c(1 To m, 1 To n) As Long
For i = 1 To m
For j = 1 To n
c(i, j) = a(i, j) - b(i, j)
Picture3.Print c(i, j);
Next j
Picture3.Print
Next i
End If
lab:
End Sub

Private Sub Command5_Click()

Picture3.Cls

If m = 0 Or n = 0 Or p = 0 Or q = 0 Then
MsgBox "请先输入矩阵", vbOKOnly, "提示"
GoTo lab:
End If

If n <> p Then
MsgBox "请输入A矩阵列数和B矩阵行数相等的矩阵再做乘积", vbOKOnly, "提示"
End If

If n = p Then
Label1.Caption = "x"
ReDim c(1 To m, 1 To q) As Long
For i = 1 To m
For j = 1 To q
For k = 1 To n
c(i, j) = a(i, k) * b(k, j) + c(i, j)
Next k
Picture3.Print c(i, j);
Next j
Picture3.Print
Next i
End If
lab:
End Sub

Private Sub Command6_Click()
Form1.Hide
Form2.Show

End Sub

Private Sub Command7_Click()
m = 0
n = 0
p = 0
q = 0

Picture1.Cls
Picture2.Cls
Picture3.Cls
Label1.Caption = ""

End Sub

Private Sub Command8_Click()
m = 0
n = 0
Picture1.Cls
End Sub

Private Sub Command9_Click()
p = 0
q = 0
Picture2.Cls
End Sub

Private Sub Timer1_Timer()

If (Label3.Left + Label3.Width < Form1.ScaleWidth And flag = 0) Or (Label3.Left < 0) Then
Label3.Left = Label3.Left + 100
flag = 0
Else
Label3.Left = Label3.Left - 100
flag = 1
End If

End Sub
Private Sub Form_Load()
flag = 0
Me.Picture = LoadPicture(App.Path & "\图片\a.jpg")

End Sub
form2
Dim flag As Integer
Private Sub Command1_Click()
Form1.Show
Form2.Hide

End Sub
Private Sub Form_Load()
flag = 0
Me.Picture = LoadPicture(App.Path & "\图片\a.jpg")

End Sub

Private Sub Timer1_Timer()

If (Label2.Left + Label2.Width < Form2.ScaleWidth And flag = 0) Or (Label2.Left < 0) Then
Label2.Left = Label2.Left + 90
flag = 0
Else
Label2.Left = Label2.Left - 90
flag = 1
End If
End Sub
自己在程序里建上图片文件夹,里面放上图片A.JPG就可以了
那个timer自己可以改下时间间隔
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式