Results 1 to 2 of 2

Thread: project help

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2003
    Posts
    33

    project help

    I need some help with my program. I am developing a program that opens files from a destination into a textbox on the form. right now I have and area where you type in the filespec of the file that I want to open. How do I set up the a browse button that will open when you click on it and allow you to go and click on whatever file that I want to open. I have seen many programs with it I think it is some kind of common dialog that I need to use. But I am not sure any help would be greatly appreciatied thanks

  2. #2
    Junior Member
    Join Date
    Dec 2003
    Location
    California
    Posts
    19
    Depending on what type of file you are using, assuming its a text file or something:

    Add a OpenFileDialog to your solution/project from the windows form controls:
    VB Code:
    1. Dim str as string
    2. Dim line as string
    3. Me.txtMyTextBox.Text = ""
    4. If Me.OpenFileDialog1.ShowDialog() = DialogResult.OK Then
    5.      str = Me.OpenFileDialog1.FileName.ToString
    6.      Dim fs as System.IO.FileStream = New System.IO.FileSteam(str, IO.FileMode.Open)
    7.      Dim sr as System.IO.StreamReader = New System.IO.StreamReader(fs)
    8.       line = sr.ReadToEnd
    9.       Me.txtMyTextBox.Text = line
    10.       sr.Close()
    11.      fs.Close()
    12. End if

    You can set parameters in the properties of the open file dialog to limit file types and so forth...

    Hope this helps
    Regards -

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width