VERSION 5.00
Begin VB.Form Form1 
   AutoRedraw      =   -1  'True
   Caption         =   "Form1"
   ClientHeight    =   2655
   ClientLeft      =   4365
   ClientTop       =   1530
   ClientWidth     =   4560
   LinkTopic       =   "Form1"
   PaletteMode     =   1  'UseZOrder
   ScaleHeight     =   2655
   ScaleWidth      =   4560
   Begin VB.PictureBox Picture3 
      Height          =   975
      Left            =   1080
      ScaleHeight     =   915
      ScaleWidth      =   2955
      TabIndex        =   6
      Top             =   1440
      Width           =   3015
   End
   Begin VB.CommandButton Command1 
      Caption         =   "合并"
      Height          =   495
      Left            =   120
      TabIndex        =   5
      Top             =   1920
      Width           =   735
   End
   Begin VB.PictureBox Picture2 
      Height          =   495
      Left            =   1080
      ScaleHeight     =   435
      ScaleWidth      =   2955
      TabIndex        =   4
      Top             =   720
      Width           =   3015
   End
   Begin VB.PictureBox Picture1 
      Height          =   495
      Left            =   1080
      ScaleHeight     =   435
      ScaleWidth      =   2955
      TabIndex        =   3
      Top             =   120
      Width           =   3015
   End
   Begin VB.Label Label3 
      Caption         =   "合并后C"
      Height          =   495
      Left            =   240
      TabIndex        =   2
      Top             =   1440
      Width           =   735
   End
   Begin VB.Label Label2 
      Caption         =   "数B"
      Height          =   495
      Left            =   240
      TabIndex        =   1
      Top             =   720
      Width           =   735
   End
   Begin VB.Label Label1 
      Caption         =   "数组A"
      Height          =   495
      Left            =   240
      TabIndex        =   0
      Top             =   240
      Width           =   735
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim A1(), B1(), C1()
Private Sub Form_Click()
  Dim i As Integer
    '对A,B数组赋初值
  A1 = Array(2, 4, 6, 8, 10)
  B1 = Array(1, 3, 5, 7, 9, 11, 13, 15)
  For i = 0 To UBound(A1)
      Picture1.Print A1(i);
  Next i
  For i = 0 To UBound(B1)
      Picture2.Print B1(i);
  Next i
  ReDim C1(UBound(A1) + UBound(B1) + 1)
End Sub

Private Sub Command1_Click()
  Call Merage(A1(), B1(), C1())        '调用合并过程
  For i = 0 To UBound(C1)
      Picture3.Print C1(i);
      If (i + 1) Mod 10 = 0 Then Picture3.Print
  Next i
End Sub
Sub Merage(A(), B(), C())
   Dim ia As Integer, ib As Integer, ic As Integer
   Dim i As Integer         '当A和B数组均未比较完
   Do While ia <= UBound(A) And ib <= UBound(B)
     If A(ia) < B(ib) Then
       C(ic) = A(ia)
       ia = ia + 1
     Else
       C(ic) = B(ib)
       ib = ib + 1
     End If
     ic = ic + 1
    Loop
    Do While ia <= UBound(A)    'A数组中的剩余元素抄入C数组
      C(ic) = A(ia)
      ia = ia + 1
      ic = ic + 1
    Loop
     Do While ib <= UBound(B)   'B数组中的剩余元素抄入C数组
      C(ic) = B(ib)
      ib = ib + 1
      ic = ic + 1
    Loop
End Sub

