-2

how to multiply two dimensional a(5,3) and b (3,5)
so the arry c( , )= a(5,3) and b (3,5)
the first row of arry a * the columns of arry b then
the second row of arry a * the columns of arry b then

[EDIT] the code of your comment:

Dim arry1(5, 3) As Integer 
Dim arry2(3, 5) As Integer 
Dim i, j As Integer 
For i = 1 To 5 
  For j = 1 To 3 
    arry1(i, j) = Int(9 * Rnd + 1) 
  Next i, j 
For i = 1 To 3 
  For j = 1 To 5 
    arry2(i, j) = Int(9 * Rnd + 1) 
  Next i, j 
Hrqls
  • 2,944
  • 4
  • 34
  • 54
Kazem
  • 1
  • 4
  • You should show what you have tried already – Rob Jan 19 '15 at 09:31
  • @rob i didnt try to multiply but cuz i stop at this point – Kazem Jan 19 '15 at 12:27
  • Dim arry1(5, 3) As Integer Dim arry2(3, 5) As Integer Dim i, j As Integer For i = 1 To 5 For j = 1 To 3 arry1(i, j) = Int(9 * Rnd + 1) Next i, j For i = 1 To 3 For j = 1 To 5 arry2(i, j) = Int(9 * Rnd + 1) Next i, j – Kazem Jan 19 '15 at 12:35
  • please edit your original post to include the code you already have ... the code you posted in the comment above does nothing except filling the arrays with random values (if the errors are corrected) .. there is no mutliplication in your code above – Hrqls Jan 19 '15 at 13:12
  • your question seems like homework of a math class ... we wont be doing your homework for you, but we can help you fix errors in the code which you already made/tried – Hrqls Jan 19 '15 at 13:14
  • am sorry gaiz its my first post :D – Kazem Jan 19 '15 at 21:49
  • @Hrqls no my frind its not dont think bad abut me :) – Kazem Jan 19 '15 at 21:50
  • @Kazem : I know it was your first post, that's why I helped you with the edit :) – Hrqls Jan 20 '15 at 08:06

2 Answers2

0
Dim a, b As Integer
Dim arry1(5, 3) As Integer
Dim arry2(3, 5) As Integer
ReDim c(5, 5) As Integer
Dim i, j, s As Integer

Print ""
Print Space(15); "the first arry"
Print ""
For i = 1 To 5
  For j = 1 To 3
   arry1(i, j) = Int(9 * Rnd + 1)
   Print Space(3); arry1(i, j);
  Next j
 Print ""
Next i
Print ""
Print Space(15); " the second arry"
Print ""
For i = 1 To 3
  For j = 1 To 5
   arry2(i, j) = Int(9 * Rnd + 1)
   Print Space(3); arry2(i, j);
  Next j
 Print ""
Next i
Print ""
Print Space(15); " the result"
Print ""
cmd1.Visible = False

For a = 1 To 5
   For b = 1 To 5
      For j = 1 To 3
      s = s + (arry1(b, j) * arry2(j, a))
      c(a, b) = s
     Next j
       s=0
  Next b
Next a

For i = 1 To 5
   For j = 1 To 5
    Print Space(3); c(i, j);
   Next j
  Print ""
Next i

thank you for your answers i solved the problem by may self and its pleasure me if you tel your openion in my code ... thank you

Kazem
  • 1
  • 4
0

Congrats! it works :)

Some comments:

  • when you use Dim a, b As Integer then b will be an Integer, but a will be a Variant. It is better to use Dim a As Integer, b As Integer so that both a and b will be Integers
  • why do you ReDim c(5, 5) As Integer ? You can use Dim c(5, 5) As Integer
  • Instead of printing to the form I would show the data in a textbox or label control
Hrqls
  • 2,944
  • 4
  • 34
  • 54
  • thank you i can use dim but i prefer use redim in result array thank you very much for this the advice i will separate the declaration but i detect an error in the program >> the variable s still save the old summation so it is add the old result to the next result in the next element of the result array [c] so we should equal it to zero in next loop it will become like this **next j** **s=0** to void summing the old result with the next result so i will edit the program – Kazem Jan 20 '15 at 14:38
  • why do you prefer to use redim for the result array? ... and if redim seems better to you, then why dont you use it for the first 2 arrays as well? – Hrqls Jan 21 '15 at 06:39