Browsing the files!!!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • eklavyavats
    New Member
    • May 2007
    • 24

    #1

    Browsing the files!!!

    Can anyone tell me how to browse a file in VB. Please let me know as soon as possible as my project is stuck because of it. Please also let me know that how we can print a file. Thanks.
  • kadghar
    Recognized Expert Top Contributor
    • Apr 2007
    • 1302

    #2
    there you go
    [CODE=vb]Dim Str1 as String

    With Application.Fil eDialog(msoFile DialogFilePicke r)
    .AllowMultiSele ct = True
    .Filters.Clear
    .Filters.Add "JPG files (*.jpg)", "*.jpg"
    .Filters.Add "All Files (*.*)", "*.*"
    .InitialFileNam e = Str1
    .Show
    If .SelectedItems. Count > 0 Then
    'Do whatever you want with str1 & selectedItems.I tem(n)
    'Or just save the complete file name to a string with
    ' dim mystring as string
    ' mystring = str1 & selecteditems.i tem(n)
    end if
    end with[/CODE]

    I put the multiselect = true, but if you set it with false, the only selected item will be item(1)

    Good Luck

    Comment

    • Killer42
      Recognized Expert Expert
      • Oct 2006
      • 8429

      #3
      Originally posted by eklavyavats
      Can anyone tell me how to browse a file in VB. Please let me know as soon as possible as my project is stuck because of it. Please also let me know that how we can print a file. Thanks.
      What do you mean exactly by "browse"? The prior response shows (I think) how to list and choose files. If you mean how to read the contents of a file, you could try hitting the index at the top of the VB forum. There are a couple of samples listed in there which show how to read a file.

      By the way, what version of VB are you using?

      Comment

      Working...