1.在Visual Basic中开始一个新的工程,采用缺省的方法建立For m1。 
  2.在Form1上添加一个公共对话框控件,采用缺省的方法建立Comm onDialog1。 
  3.在Form1上添加一个文本框控件,采用缺省的方法建立Text1。 
  4.在Form1上添加第二个文本框控件,采用缺省的方法建立Text2 。将它的MultiLine 属性设置为True。 
  5.在Form1上添加一个命令按钮控件,采用缺省的方法建立Comand 1。将它的Caption 属性设置为"打开文件对话框"。 
  6.将如下代码添加到Command1的单击事件中: 
  Private Sub Command1_Click() 
  Dim I As Integer 
  Dim Y As Integer 
  Dim Z As Integer 
  Dim FileNames$() 
  Const OFN_ALLOWMULTISELECT = &H200& 
  CommonDialog1.filename = "" 
  CommonDialog1.Filter = "All Files|*.*" 
  CommonDialog1.Flags = OFN_ALLOWMUL- SELECT 
  CommonDialog1.Action = 1 
  CommonDialog1.filename = CommonDialog1. filename & Chr(3 2) 
  Z = 1 
  For I = 1 To Len(CommonDialog1.filename) 
  I = InStr(Z, CommonDialog1.filename, Chr(32)) 
  If I = 0 Then Exit For 
  ReDim Preserve FileNames(Y) 
  FileNames(Y) = Mid(CommonDialog1.filename, Z, I - Z) 
  Z = I + 1 
  Y = Y + 1 
  Next 
  If Y = 1 Then 
  Text1.Text = FileNames(0) 
  Else 
  Text 2.Text = "" 
  For I = 0 To Y - 1 
  If I = 0 Then 
  Text1.Text = FileNames(I) 
  Else 
  Text2.Text = Text2.Text & UCase(FileNames(I)) & Chr$(13) & Chr$(10) 
  End If 
  Next 
  End If 
  End Sub