Solved

Saving the same picture in different folder using VB6

Posted on 2003-11-26
5
534 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
5 Comments
 
LVL 24

Assisted Solution

by:shivsa
shivsa earned 25 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 25 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 200 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
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 pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

832 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