+ Reply to Thread
Results 1 to 10 of 10

Inverse and multiplication of Matrices In VBA

  1. #1
    Registered User
    Join Date
    11-25-2008
    Location
    Poland
    Posts
    25

    Inverse and multiplication of Matrices In VBA

    1) I have declared:

    Mtrx(20,20) as Integer, where i have a Matrix

    1 2 3
    1 2 3

    How can I do an inverse of this matrix using only VBA commands?


    2) I have :
    Mtrx(20,20) as Integer, for example :

    3 1
    2 0

    and Mtrx1(20,20) as Integer :
    1 2 0
    0 1 1

    How to multiply these matrices using only VBA ?

    Thanks a lot for your help

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    11-25-2008
    Location
    Poland
    Posts
    25
    Ummm... I think you used an excel worksheet to make it, but i cant use it actually. Is it possible?

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    11-25-2008
    Location
    Poland
    Posts
    25
    It does not work here... Where should i put my arrays Mtrx and Mtrx1, which are declared as Arrays(20,20) of Integers? sorry for problems...
    Last edited by adashiu; 11-30-2008 at 01:53 PM.

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    You're going to have to explain more clearly what you are trying to do.

  7. #7
    Registered User
    Join Date
    11-25-2008
    Location
    Poland
    Posts
    25

    Wink

    Look :
    Im doing a VBA program, which will multiply and do an inverse of a matrix.
    I have created a form, similar to this:

    form1.jpg

    But a user can define number of rows and columns.
    I store all data entered by user to TextBoxes in previously delcared array Mtrx(20,20) as Integer.

    I have the same for where user put data for another matrix Mtrx1.

    So i have Matrix filled with a data of user.

    For example :
    User wants to multiply a Matrix 2x2 with a Matrix 2x3. He puts data to Mtrx and Mtrx1.

    And now if i have this data inside my Mtrx and Mtrx1. I want to multiply those 2 matrices. I hope You understand now

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    So load the data from the text boxes into the two matrices, and multiply as in the example I posted, changing the variable names to agree with yours:
    Please Login or Register  to view this content.
    You must use a Variant to receive the result.

  9. #9
    Registered User
    Join Date
    11-25-2008
    Location
    Poland
    Posts
    25

    Unhappy

    I did so but it does not work... Run-Time Error '1004'.

    I have created a sample file with 2 matrices. Could you apply your code to my sample file? And make multiplied matrix to show on Excel Sheet? It would really help me. Sorry for troubles. I hope i would be able to help you in future.

    SampleMatrix.xls

    Greets, Adam

  10. #10
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    Run this in a scratch workbook:
    Please Login or Register  to view this content.
    Remarks:

    1. Arrays have a default base of 0 in each dimension, unless you use Option Base 1 (not recommended). You should declare array extents explicitly.

    2. If you're going to vary the size of arrays, they must be dynamic, as illustrated above. Help covers this.
    Last edited by shg; 11-30-2008 at 08:28 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1