Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Saving the same picture in different folder using VB6

Posted on 2003-11-26
5
Medium Priority
?
561 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
Windows Script Host (WSH) has been part of Windows since Windows NT4. Windows Script Host provides architecture for building dynamic scripts that consist of a core object model, scripting hosts, and scripting engines. The key components of Window…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

618 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