Hi, I'm new to VB :sweat:
Basically what I am trying to achieve is a browse button where the user is required to find a location for the file that my program will be creating. I'll give an example.

|TextBox1| (Button4)
When button4 is clicked it will open up a save file dialog. The user then finds the location of where they would like to save the file. They type a file name like "picture001" then the program automatically ads on a .jpg file format when they click Save.

Upon clicking save the file path ex. C:\picture001.jpg will be written into TextBox1. TextBox1 will not be manually editable by the user (Don't worry I think I've got that bit solved).

And of-course to show I've spent effort I'll post the sub I have so far. It creates the file you type into it only in .jpg format but then it locks up the program! :icon_cry: The code is not stable and I've tried playing around with it

Public Class OneTapWebToPicture

    Private Sub Button4_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button4.Click
        Dim saveFileDialog1 As New SaveFileDialog()
        saveFileDialog1.Filter = "jpeg Image|*.jpg"
        saveFileDialog1.Title = "Locate Where To Save File Please."
        saveFileDialog1.ShowDialog()

        ' If the file name is not an empty string open it for saving.
        If saveFileDialog1.FileName <> "" Then
            ' Saves the Image via a FileStream created by the OpenFile method.
            Dim fs As System.IO.FileStream = CType _
               (saveFileDialog1.OpenFile(), System.IO.FileStream)
            ' Saves the Image in the appropriate ImageFormat based upon the
            ' file type selected in the dialog box.
            ' NOTE that the FilterIndex property is one-based.
            fs.Close()
        End If
    End Sub

Thanks!

Try this. And you can set the TextBox's ReadOnly property to true so that the user can not edit it. I did it in code below but you can set it right in the properties window so its not re-running every time (although it wont hurt anything just isnt needed to run more then once)

Dim dlgSaveFile As New SaveFileDialog()

        dlgSaveFile.Filter = "jpeg Image|*.jpg"
        dlgSaveFile.Title = "Locate Where To Save File Please."
        If dlgSaveFile.ShowDialog <> Windows.Forms.DialogResult.OK Then Exit Sub

        TextBox1.ReadOnly = True
        TextBox1.Text = dlgSaveFile.FileName

        'Code to save file(s) here....
Comments
Incredibly useful, could not find a solution anywhere else! Thanks
This question has already been answered. Start a new discussion instead.