Home > Software engineering >  The subscript crossing the line, how to solve? For a great god
The subscript crossing the line, how to solve? For a great god

Time:10-10

 () As Single Dim a, b () As Single 
N=Text1. Text
ReDim a (n)
For I=1 To n
A (I)=InputBox (" please enter a (" & amp; i & ") ")
Next I
M=Text1. Text
ReDim b (m)
For j=1 To m
B (j)=InputBox (please input (" b "& amp; J & amp; ") ")
Next j
C=creatematrix (a (I))
D=creatematrix (j) (b)
X=times (c, d)
The Sum (x)
The Sum (x). The Show

CodePudding user response:

ReDim a (n + 1)
A similar

Another creatematrix code does not see,

CodePudding user response:

 () As Single Dim a, b () As Single 
N=Text1. Text
ReDim a (n)
For I=1 To n 'this place bounds, change For I=0 To n - 1
A (I)=InputBox (" please enter a (" & amp; i & ") ")
Next I
M=Text1. Text
ReDim b (m)
For j=1 To m 'this place of crossing the line, change the For j=0 To m - 1
B (j)=InputBox (please input (" b "& amp; J & amp; ") ")
Next j
C=creatematrix (a (I))
D=creatematrix (j) (b)
X=times (c, d)
The Sum (x)
The Sum (x). The Show

CodePudding user response:

Change of two places:
ReDim a (1 To n)
ReDim (1 To m b)
Because the default start index is 0

C=creatematrix (a (n))
D=creatematrix (m) (b)
Because at the end of the loop, loop variable is greater than the upper limit of you, so will be crossing the line,

CodePudding user response:

0 to N - 1 rewritten
  • Related