Home > Software engineering >  VB matrix computation, output in the text box, but when calculating additive has been subscript boun
VB matrix computation, output in the text box, but when calculating additive has been subscript boun

Time:11-07

Option 1 'form module Base general statements set lower bound for each dimension array in 1
Dim (a) As an Integer, and (b) As an Integer, c () As an Integer, I %, j % 'form module general statement section definition module series group and module-level variables

Private Sub Command1_Click ()
ReDim c (m, n)
Text3. Text=""
P=""
For I=1 To m
For j=1 To n
C (I, j)=a (I, j) + b (I, j) 'matrix addition
P=p & amp; Str (a (I, j))
Next
P=p & amp; VbCrLf
Next
Text3. Text=p


End Sub

Private Sub Form_click ()
Dim I As an Integer, j defining variables As Integer '
Rows of the matrix m=InputBox (" input ", "data input") 'InputBox function input matrix rows
N=InputBox (" input the number of columns of the matrix, "" data input") 'use InputBox function input the number of columns of the matrix
Rem definition matrix and output
ReDim a (m, n)
ReDim b (m, n)
Randomize
Text1=""
For I=1 To m
For j=1 To n
A (I, j)=Int (Rnd * 50 + 1)
Text1=Text1 & amp; The Format (a (I, j), "@ @ @ @")
Next j
Text1=Text1 & amp; CRH (13) & amp; CRH (10)
Next I
Randomize
Text2=""
For I=1 To m
For j=1 To n
B (I, j)=Int (Rnd * 50 + 1)
Text2=Text2 & amp; The Format (b (I, j), "@ @ @ @")
Next j
Text2=Text2 & amp; CRH (13) & amp; CRH (10)
Next I
End Sub
  • Related