然后添加到LISTBOX中???很急,谢谢!!

解决方案 »

  1.   

    呵呵~~可以将FileListBox来代替,就方便多了么。
      

  2.   

    Private Sub Command1_Click()
     '首先 要从工程 部件 中选择加载 Microsoft Common Dialog Control 6.0
        Me.CommonDialog1.DialogTitle = "open file"
        Me.CommonDialog1.Filter = "bmp files(*.bmp)|*.bmp|jpg files(*.jpg)|*.jpg|all files(*.*)|*.*"
        Me.CommonDialog1.ShowOpen
      
        Dim s As String
        s = CommonDialog1.FileName
        Dim arr
        arr = Split(s, Chr(0))
        Dim path As String
        Dim file1 As String
        Dim i As Long
        i = InStrRev(arr(0), "\")
        List1.Clear
        If i > 0 Then
            'path = Left(arr(0), i - 1)
            path = IIf(Right(arr(0), 1) = "\", arr(0), arr(0) & "\")
            If UBound(arr) >= 1 Then
                For i = 1 To UBound(arr)
                    List1.AddItem path + arr(i)
                Next
            Else
                List1.AddItem s
            End If
        End If
    End Sub
      

  3.   

    Public Function GetFile(SoftPath As String)
    Dim fn, mypath, myname, dirfp As String
    fn = SoftPath
    If Right(fn, 1) = "\" Then
        mypath = fn
    Else
        mypath = fn & "\"
    End If
    th = mypath & "*.*"
    myname = Dir(mypath, 0)
    Do While myname <> ""
        list1.AddItem myname
        myname = Dir
    Loop
    End Function
      

  4.   

    呵呵
    楼主的意思呢?
    也可以使用fso对象。
      

  5.   

    我是要把文件名显示在LISTBOX中,这个PATH是固定的,用户选择后再把图片显示在图象控件中我其实不是做VB的,公司里人手不够(其实也很少接到VB的活),只能硬着头皮上。谢谢,不知道能不能提供一下把图片显示在图象控件中的代码,分给少了,一定加
      

  6.   

    可能你想做的图片浏览的
    建议Option Explicit
    '添加driverlistbox,dirlistbox,filelistbox,picturebox控件Private Sub Dir1_Change()
    File1.Path = Dir1.Path
    File1.Pattern = "*.bmp;*.jpg"
    End SubPrivate Sub Drive1_Change()
    Dir1.Path = Drive1.Drive
    End SubPrivate Sub File1_Click()
    Picture1.Picture = LoadPicture(File1.Path + "\" + File1.FileName)
    End Sub
      

  7.   

    要把一个图片显示在窗体上,可以使用IMAGE控件,
    IMAGE.PICTURE=LOADPICTURE(FILENAME)  'FILENAME包含路径和文件名
      

  8.   

    大概是我没有说明白,我的意思是从一个已知的目录下(这个目录是专门用来放图片的,没有其他东西),读出全部的图片的名称,自动放入一个ListBox中,只取名字。没有其他操作。只有两个步骤:1.取得文件(图片)名称
                  2.放如ListBox中谢谢。
      

  9.   

    建议用文件列表框:FileListBox
      

  10.   

    Private Sub Command1_Click()
    Dim fs
    Set fs = CreateObject("scripting.filesystemobject")
    Dim f, f1
    Set f = fs.getfolder("c:\bmp")
    For Each f1 In f.Files
    List1.AddItem f1.Name
    Next
    End Sub