Results 1 to 4 of 4

Thread: [RESOLVED] save picture filename with common dialog

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Resolved [RESOLVED] save picture filename with common dialog

    I have problem here. I want to save the image from picture box to my computer. I use common dialog, the filename is extract form text21. But When I change this filename to other filename, It save without extension *.jpg. But If I follow what the filename given, it save with extension *.jpg. How I use recommended filename or my own filename and save it with extension at the end of the filename.

    Code:
    'SAVE pest picture from picturebox to file
    With CommonDialog2
        .fileName = Text21.Text & ".jpg"
        .Filter = "Image (*.*)|*.*"
        .ShowSave
        If Len(.fileName) <> 0 Then
        SavePicture Picture2.Image, CommonDialog2.fileName
        MsgBox "File berjaya disimpan di " & CommonDialog2.fileName
        End If
    End With

  2. #2

    Re: save picture filename with common dialog

    hi please try as following
    i hope this is what you are trying to achive if not please clarify further
    it will show untitled.jpg as default if you are selecting option 1
    if you are selecting option two will show all the jpg files


    vb Code:
    1. [CODE]
    2.  With CommonDialog2
    3.         .FileName = Text21.Text & ".jpg"
    4.         .Filter = "Preferred Image (untitled.JPG)|untitled.JPG|Image (*.jpg)|*.jpg|All Files (*.*)|*.*"
    5.         .ShowSave
    6.         If Len(.FileName) <> 0 Then
    7.         SavePicture Picture2.Image, CommonDialog2.FileName
    8.         MsgBox "File berjaya disimpan di " & CommonDialog2.FileName
    9.         End If
    10.     End With[/CODE]

  3. #3
    Fanatic Member vivek_master146's Avatar
    Join Date
    Apr 2006
    Location
    Delhi,India
    Posts
    787

    Re: save picture filename with common dialog

    Use this
    Code:
    Private Sub Command1_Click()
    With CommonDialog2
        .FileName = Text21.Text & ".jpg"
        .Filter = "Image (*.jpg)|*.jpg"
        .ShowSave
        If Len(.FileName) <> 0 Then
        SavePicture Picture2.Image, CommonDialog2.FileName
        MsgBox "File berjaya disimpan di " & CommonDialog2.FileName
        End If
    End With
    
    End Sub
    Dont rely only on your luck. Work hard until You get success.
    vb Code:
    1. Private sub Time_ispassing
    2. While Me.Notgetsuccess
    3. trygain=tryagain+1
    4. Me.workhard
    5. wend
    6. end sub

  4. #4
    PowerPoster Keithuk's Avatar
    Join Date
    Jan 2004
    Location
    Staffordshire, England
    Posts
    2,236

    Re: [RESOLVED] save picture filename with common dialog

    But you can't save a picture as a jpg it always saves as a bmp unless you are using Bmp2jpeg.dll. Do a search on here for Bmp2jpeg.dll.
    Keith

    I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.

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