Solved

Saving the same picture in different folder using VB6

Posted on 2003-11-26
5
514 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Using Powershell to monitor file changes then execute a command 5 94
has12 challenge 13 58
java ^ examples 8 57
sameEnds challenge 25 72
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…
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…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…

762 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now