How to put file nameautomatically from text box when save dialog box appear

Viewed 43

iam already use this code to save image file i want when save dialog box appear take the file name from text which inside textbox written by hand or barcode scanner

enter image description here

   Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
        Dim data As IDataObject
        Dim bmap As Image

        ' Copy image to clipboard
        SendMessage(hHwnd, WM_CAP_EDIT_COPY, 0, 0)

        ' Get image from clipboard and convert it to a bitmap

        data = Clipboard.GetDataObject()
        If data.GetDataPresent(GetType(System.Drawing.Bitmap)) Then
            bmap = CType(data.GetData(GetType(System.Drawing.Bitmap)), Image)
            picCapture.Image = bmap
            PictureBox1.Image = picCapture.Image
            If sfdImage.ShowDialog = DialogResult.OK Then
                sfdImage.FileName = TextBox1.Text
                If InStr(sfdImage.FileName, ".bmp") Then

                    bmap.Save(sfdImage.FileName, Imaging.ImageFormat.Bmp)

                Else
                    bmap.Save(sfdImage.FileName, Imaging.ImageFormat.Jpeg)

                End If
            End If
        End If
    End Sub
0 Answers
Related