工程form1中的代码如下:
Option Base 1
Dim b() As Integer
Dim a() As Integer
Private Sub Form_Load()
Form1.AutoRedraw = True
ReDim a(10)
For i = 1 To 5
a(i) = i * 2
Print a(i);
Next i
End Sub
Private Sub Command1_Click()
Static b As Integer, x As Integer
b = b + 1
If b Mod 2 <> 0 Then
x = Val(InputBox("请输入要插入的数:"))
Call fact1(a(), x)
End IfEnd Sub
module1中的代码如下:
Option Base 1
Public Sub fact1(b() As Integer, y As Integer)
For i = LBound(b) To UBound(b)
If y < b(i) Then Exit For
Next i
ReDim Preservea(UBound(b) + 1)
For j = UBound(b) - 1 To i Step -1
b(j + 1) = b(j)
Next j
b(j) = y
End Sub
但是没有结果输出,请问这是怎么会事????
Option Base 1
Dim b() As Integer
Dim a() As Integer
Private Sub Form_Load()
Form1.AutoRedraw = True
ReDim a(10)
For i = 1 To 5
a(i) = i * 2
Print a(i);
Next i
End Sub
Private Sub Command1_Click()
Static b As Integer, x As Integer
b = b + 1
If b Mod 2 <> 0 Then
x = Val(InputBox("请输入要插入的数:"))
Call fact1(a(), x)
End IfEnd Sub
module1中的代码如下:
Option Base 1
Public Sub fact1(b() As Integer, y As Integer)
For i = LBound(b) To UBound(b)
If y < b(i) Then Exit For
Next i
ReDim Preservea(UBound(b) + 1)
For j = UBound(b) - 1 To i Step -1
b(j + 1) = b(j)
Next j
b(j) = y
End Sub
但是没有结果输出,请问这是怎么会事????
-----------------
ReDim Preserve a(UBound(b) + 1)
少个空格
Dim b() As Integer
Dim a() As Integer
Private Sub PrintArr(arr() As Integer)
Me.Cls
Dim i As Long
For i = LBound(arr) To UBound(arr)
Print arr(i);
Next
End Sub
Private Sub Form_Load()
Form1.AutoRedraw = True
ReDim a(10)
For i = 1 To 10
a(i) = i * 2
Next i
PrintArr a
End Sub
Private Sub Command1_Click()
Static b As Integer, x As Integer
b = b + 1
If b Mod 2 <> 0 Then
x = Val(InputBox("请输入要插入的数:"))
Call fact1(a(), x)
PrintArr a
End If
End Sub
module1中的代码如下:Option Base 1
Public Sub fact1(b() As Integer, y As Integer)
For i = LBound(b) To UBound(b)
If y < b(i) Then Exit For
Next i
Debug.Print i
ReDim Preserve b(UBound(b) + 1)
For j = UBound(b) - 1 To i Step -1
b(j + 1) = b(j)
Next j
b(j + 1) = y
End Sub