?
Solved

Saving the same picture in different folder using VB6

Posted on 2003-11-26
5
Medium Priority
?
555 Views
Last Modified: 2008-03-17
Ok, this is what I want to happen in my program, I have this picture box or image box inside my form1, and there were 2 buttons on it, one is Open Picture, and the other is Save picture. Once I press the Open Picture, I can open any picture(jpeg or gif) in any folder in my drive C, for example I've open a jpeg image in my "My documents" folder. When I press Save button, the picture will be save in my "C:\Image\" folder. I've already done everything expect the save button....I'm having problem saving the image file to a different folder. Any help will do. Thanks in Advance.
0
Comment
Question by:bawasi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 24

Assisted Solution

by:shivsa
shivsa earned 100 total points
ID: 9829961
try this link.
-----------------------
http://www.informit.com/isapi/product_id~{3EBD1237-3C91-4CF3-A0BA-EB3976CD978B}/element_id~{43EC34DD-E564-4F64-9585-614F65728ED6}/st~{8B377B75-8B63-4AEA-BEA1-4917BA2DDED0}/session_id~{30F0AE92-7082-4D72-852E-64655747A316}/content/articlex.asp#Heading3
0
 
LVL 8

Assisted Solution

by:_corey_
_corey_ earned 100 total points
ID: 9830240
Will there be any changes to the picture?  Do you want to save the data that is loaded into the display box or just copy the file from one location to another?

If you like, you could simply take the filename that you used to open it, and open it manually, open the new location, and read/write until you are done.

0
 

Author Comment

by:bawasi
ID: 9830437
No there will be no changes in the picture. And yes what is shown in the display box is what i want to save into different folder. And I want to the program to save it for me to the different folder.

Actually, in saving the image that is being displayed in the display box, if it is possible, I dont want to use a dialog box, I want it to be automatically save to the path that I specify in my code...for example "c:\images\". thats all.
0
 
LVL 6

Accepted Solution

by:
mirzas earned 800 total points
ID: 9831456
Could this help?


Option Explicit

Private Sub OpenAndSave(ByRef targetPictureBox As PictureBox, ByVal fOpenPath, ByVal fSavePath As String)
    targetPictureBox.Picture = LoadPicture(fOpenPath)
    Call FileCopy(fOpenPath, IncludeSlash(fSavePath) & GetName(fOpenPath))
End Sub


Function GetName(ByVal s As String) As String
    Dim i As Integer
    Dim tmp As String
   
    tmp = ""
    i = Len(s)
    Do While i > 1
        If Mid(s, i, 1) = "\" Then
            i = 0
        Else
            tmp = Mid(s, i, 1) & tmp
        End If
        i = i - 1
    Loop
    GetName = tmp
   
End Function

Function IncludeSlash(ByVal s As String) As String
   
    If Mid(s, Len(s), 1) <> "\" Then
        IncludeSlash = s & "\"
    Else
        IncludeSlash = s
    End If
End Function

Private Sub cmdOpen_Click()
    'open and copy
    Call OpenAndSave(Picture1, "C:\test.jpg", "D:\")
End Sub
0
 

Expert Comment

by:lonsoft
ID: 9894368
Only one line code:
  SavePicture Picture1.Picture ,"C:\Image\yourNewFileName.bmp"
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question