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

📄 matrixcalculate.frm

📁 一个不仅可以进行常规运行(常规运算能一下计算一个多项式如:1.2*2-3*(3.5+6.7)...)还可以计算矩阵运算的计算机器
💻 FRM
📖 第 1 页 / 共 2 页
字号:
VERSION 5.00
Begin VB.Form MatrixCalculate 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "矩阵运算"
   ClientHeight    =   3840
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   8925
   LinkTopic       =   "Form2"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   3840
   ScaleWidth      =   8925
   ShowInTaskbar   =   0   'False
   StartUpPosition =   3  'Windows Default
   Begin VB.TextBox Result 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   2055
      Left            =   6000
      MultiLine       =   -1  'True
      ScrollBars      =   3  'Both
      TabIndex        =   8
      Top             =   1560
      Width           =   2535
   End
   Begin VB.ComboBox KindOfCalculate 
      Height          =   300
      ItemData        =   "MatrixCalculate.frx":0000
      Left            =   2160
      List            =   "MatrixCalculate.frx":0016
      TabIndex        =   7
      Text            =   "矩阵运算"
      Top             =   240
      Width           =   1095
   End
   Begin VB.CommandButton Clrscr 
      Caption         =   "重置"
      Height          =   855
      Left            =   5760
      TabIndex        =   6
      Top             =   120
      Width           =   1335
   End
   Begin VB.CommandButton Calculate 
      Caption         =   "计算"
      Height          =   855
      Left            =   3840
      TabIndex        =   5
      Top             =   120
      Width           =   1335
   End
   Begin VB.TextBox Matrix2 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   2055
      Left            =   3360
      MultiLine       =   -1  'True
      ScrollBars      =   3  'Both
      TabIndex        =   1
      Top             =   1560
      Width           =   2415
   End
   Begin VB.TextBox Matrix1 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   2055
      Left            =   360
      MultiLine       =   -1  'True
      ScrollBars      =   3  'Both
      TabIndex        =   0
      Top             =   1560
      Width           =   2415
   End
   Begin VB.Label Label1 
      Caption         =   "结果:"
      Height          =   255
      Left            =   5880
      TabIndex        =   9
      Top             =   1200
      Width           =   855
   End
   Begin VB.Label Label5 
      Caption         =   "矩阵2:"
      Height          =   255
      Left            =   2760
      TabIndex        =   4
      Top             =   1200
      Width           =   735
   End
   Begin VB.Label Label4 
      Caption         =   "矩阵1:"
      Height          =   255
      Left            =   120
      TabIndex        =   3
      Top             =   1200
      Width           =   855
   End
   Begin VB.Label sign 
      Height          =   375
      Left            =   2280
      TabIndex        =   2
      Top             =   1680
      Width           =   375
   End
End
Attribute VB_Name = "MatrixCalculate"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim matrix1StrData(9, 9) As String
Dim matrix2StrData(9, 9) As String
Dim matrix1Data(9, 9) As Double                         '存放矩阵1中的数据
Dim matrix2Data(9, 9) As Double                         '存放矩阵2中的数据
Dim currentRow1 As Integer                              '存放矩阵1的行数
Dim currentColumn1 As Integer                          '存放矩阵1的列数
Dim currentRow2 As Integer                              '存放矩阵2的行数
Dim currentColumn2 As Integer                           '存放矩阵2的列数
Dim resultData(9, 9) As Double                          '存放运的结果
'得到输入框矩阵1的数据将其放入到数组matrix1Data中
Private Sub getMatrix1Data()
Dim matrix1Str As String                    '存放矩阵输入框中的字符串
Dim tempStr As String                       '存放当前处理字符
Dim tempLen As Integer                      '存放当符串中的长度
Dim i, j As Integer
Dim data1Len As Integer
Dim sign As Boolean                         '标识一个数是否为负数

sign = False
currentRow1 = 0
currentColumn1 = 0

matrix1Str = fliter(Matrix1.Text)                   '得到欲处理的矩阵据数,去掉了每行开始无用的空格

data1Len = Len(matrix1Str)                          '获得长度
tempLen = data1Len

For i = 0 To 9                                      '将矩阵数据清零,以方便以后再计算
    For j = 0 To 9
        matrix1Data(i, j) = 0
        matrix1StrData(i, j) = ""
    Next j
Next i

If tempLen > 0 Then                                 '循环得到输入框矩阵1的数据并将数分别放入数组matrix1Data中
    tempStr = Left(matrix1Str, 1)
    tempLen = tempLen - 1
    matrix1Str = Right(matrix1Str, tempLen)

    Do While tempLen >= 0                           '处理空格,数据用空格隔开
        If Asc(tempStr) = 32 Then
            Do While Asc(tempStr) = 32
                tempStr = Left(matrix1Str, 1)
                tempLen = tempLen - 1
                matrix1Str = Right(matrix1Str, tempLen)
            Loop
            currentColumn1 = currentColumn1 + 1
        ElseIf Asc(tempStr) = 13 Or Asc(tempStr) = 10 Then          '处理回车,换行,一个回车换行标志一行结束
            matrix1Str = Right(matrix1Str, tempLen - 1)
            tempLen = tempLen - 1
            If tempLen <= 0 Or Asc(maxChar(matrix1Str)) < 48 Then       '看下面是否还有有用字符,---数字
                Exit Do
            Else
                tempStr = Left(matrix1Str, 1)
                tempLen = tempLen - 1
                matrix1Str = Right(matrix1Str, tempLen)
                currentRow1 = currentRow1 + 1
                currentColumn1 = 0
            End If
        ElseIf (Asc(tempStr) >= 48 And Asc(tempStr) <= 57) Or Asc(tempStr) = 45 Or Asc(tempStr) = 46 Then
           Do While (Asc(tempStr) >= 48 And Asc(tempStr) <= 57) Or Asc(tempStr) = 45 Or Asc(tempStr) = 46
                matrix1StrData(currentRow1, currentColumn1) = matrix1StrData(currentRow1, currentColumn1) + tempStr
                tempStr = Left(matrix1Str, 1)
                tempLen = tempLen - 1
                If tempLen <= 0 Then
                    Exit Do
                Else
                    matrix1Str = Right(matrix1Str, tempLen)
                End If
           Loop
        End If
    Loop
Else
    MsgBox ("矩阵1输入框中为空")
End If

For i = 0 To currentRow1
    For j = 0 To currentColumn1
        matrix1Data(i, j) = Val(matrix1StrData(i, j))
    Next j
Next i


End Sub
'得到输入框矩阵2的数据将其放入到数组matrix2Data中
Private Sub getMatrix2Data()
Dim matrix2Str As String
Dim tempStr As String
Dim tempLen As Integer
Dim i, j As Integer
Dim data2Len As Integer
Dim sign As Boolean

sign = False
currentRow2 = 0
currentColumn2 = 0

matrix2Str = fliter(Matrix2.Text)               '得到欲处理数据,即掉了每行开始的空格

data2Len = Len(matrix2Str)
tempLen = data2Len

For i = 0 To 9
    For j = 0 To 9
        matrix2Data(i, j) = 0
        matrix2StrData(i, j) = ""
    Next j
Next i

If tempLen > 0 Then
    tempStr = Left(matrix2Str, 1)
    tempLen = tempLen - 1
    matrix2Str = Right(matrix2Str, tempLen)

    Do While tempLen >= 0
        If Asc(tempStr) = 32 Then
            Do While Asc(tempStr) = 32
                tempStr = Left(matrix2Str, 1)
                tempLen = tempLen - 1
                matrix2Str = Right(matrix2Str, tempLen)
            Loop
            currentColumn2 = currentColumn2 + 1
        ElseIf Asc(tempStr) = 13 Or Asc(tempStr) = 10 Then
            matrix2Str = Right(matrix2Str, tempLen - 1)
            tempLen = tempLen - 1
            If tempLen <= 0 Or Asc(maxChar(matrix2Str)) < 48 Then
                Exit Do
            Else
                tempStr = Left(matrix2Str, 1)
                tempLen = tempLen - 1
                matrix2Str = Right(matrix2Str, tempLen)
                currentRow2 = currentRow2 + 1
                currentColumn2 = 0
            End If
        ElseIf (Asc(tempStr) >= 48 And Asc(tempStr) <= 57) Or Asc(tempStr) = 45 Or Asc(tempStr) = 46 Then
           Do While (Asc(tempStr) >= 48 And Asc(tempStr) <= 57) Or Asc(tempStr) = 45 Or Asc(tempStr) = 46
                matrix2StrData(currentRow2, currentColumn2) = matrix2StrData(currentRow2, currentColumn2) + tempStr
                tempStr = Left(matrix2Str, 1)
                tempLen = tempLen - 1
                If tempLen <= 0 Then
                    Exit Do
                Else
                    matrix2Str = Right(matrix2Str, tempLen)
                End If
           Loop
        End If
    Loop
Else
    MsgBox ("矩阵2输入框中为空")
End If

For i = 0 To currentRow2
    For j = 0 To currentColumn2
        matrix2Data(i, j) = Val(matrix2StrData(i, j))
    Next j
Next i


End Sub



'根据计算种类计算
Private Sub Calculate_Click()

Select Case KindOfCalculate.Text
        Case "取逆"
            MsgBox ("you choose the opposite")
            Call getMatrix1Data
            'Call opposite
        Case "减"
            'MsgBox ("you choose the minus")
            Call getMatrix1Data
            Call getMatrix2Data
            Call minus
        Case "加"
            'MsgBox ("you choose the add")
            Call getMatrix1Data

⌨️ 快捷键说明

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