473,770 Members | 4,544 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

HELP ! Picture Box problems

3 New Member
My problem consits of the following:-

i am creating mulitple picturebox's, when the user double clicks on the picture box it opens the opendialog box to load a picture (jpeg only) into the picture box.

using this code:-

Expand|Select|Wrap|Line Numbers
  1. 'opens file dialog box to load selected jpeg into picture box
  2.         OpenFD.InitialDirectory = "C:\My Documents\My Pictures"
  3.         OpenFD.Title = "Open a JPEG file"
  4.         OpenFD.Filter = "JPEG Files(*.jpg)|*.jpg"
  5.         OpenFD.ShowDialog()
  6.  
  7.         'selected jpeg converts it to string and then loads it into picbox
  8.         If OpenFD.FileNames.Length > 0 Then
  9.             Dim img As New Bitmap(OpenFD.FileName.ToString())
  10.             PictureBox1.Image = img
  11.             PictureBox1.Refresh()
  12.         End If
When they have finished loading pictures they press a button (save button) to save the picture's into certain files called Module1.jpeg, Module2.jpeg and so on. These files are created and saved automatically (i.e. not using the save dialog box).

using this code:-

Expand|Select|Wrap|Line Numbers
  1.  Try
  2.             If PictureBox1.Enabled = True Then
  3.                 PictureBox1.Image.Save(FilePic1)
  4.             End If
  5.         Catch ex As NullReferenceException
  6.         Catch ex As Exception
  7.         End Try



here is the problem code:-

Expand|Select|Wrap|Line Numbers
  1. Try
  2.             If PictureBox1.Enabled = True Then
  3.                 PictureBox1.Image.Save(FilePic1)
  4.             End If
  5.         Catch ex As NullReferenceException
  6.         Catch ex As Exception
  7.         End Try
this works first time around, it saves the image to the (filepic1) and when loaded back in by this code:-

Expand|Select|Wrap|Line Numbers
  1. Try
  2.             Dim img1 As Image
  3.             Dim fs1 As New FileStream(FilePic1, IO.FileMode.OpenOrCreate)
  4.             img1 = Image.FromStream(fs1, OpenShare.Shared)
  5.             fs1.Close()
  6.             PictureBox1.Image = img1
  7.             PictureBox1.Refresh()
  8.         Catch ex As System.ArgumentException
  9.         Catch ex As IOException
  10.         End Try
it works fine. Its just when you press save again without changing the image(i.e. opening up dialog box and selecting new pic) it does not save anything !

close the programme and load the pictures back into there picturebox's respectfully and the ones that were not changed shows a blank picture box.

im really struggling with this can any one help :-(
Mar 1 '07 #1
1 1896
Dököll
2,364 Recognized Expert Top Contributor
Try reloading the form with:

Unload Me
About.Show
End Sub


(About being your form name then .Show)


About is a form of mine I wanted to show after performing certain tasks.
Unload Me close the form with your picture boxes, YourForm.Show will bring in form you want to its original state, therefore you can save an additional picture, assuming all pics are on the same form.

Please write again if this does not do it.

Dököll
Mar 4 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
13879
by: Trevor Fairchild | last post by:
I am making a program that categorizes pictures. The picture paths are stored in an Access Database, vb6 connects using adodc controls. This program works specifically with .jpg files. It will be used by people categorizing thousands of images. The problem I have is that both the picture control, and the image control seem unable to open certain jpg images for an unknown reason. The error message simply states "Invalid Picture". I can...
0
3478
by: abcd | last post by:
kutthaense Secretary Djetvedehald H. Rumsfeld legai predicted eventual vicmadhlary in Iraq mariyu Afghmadhlaistmadhla, kaani jetvedehly after "a ljetvedehg, hard slog," mariyu vede legai pressed Pentagjetvedeh karuvificials madhla reachathe strategy in karkun campaign deshatinst terrorism. "mudivae maretu winning or losing karkun global varti jetvedeh terror?" Mr. Rumsfeld adugued in a recent memormariyuum. vede velli jetvedeh madhla...
2
12407
by: Bill N. | last post by:
Using VB .Net 2003 Standard Edition. This simple form has a "File in Use" problem while the executable is running. Created this simple program to make sure that I hadn't done something in my code in the "real" project. In the "real" project, One part of the program saves multiple images and another part of the program moves the images to the appropriate directories based on user feedback.
4
12850
by: NASAdude | last post by:
I'm working on distributing a database using VS Tools for Office, and am having trouble with linked images on forms/reports. The image objects have a default path\file set on the .Picture property, which becomes invalid when the user installs the database (ie: c:\devpath\ becomes c:\program files\mydbapp, but the .Picture property still points to c:\devpath\) The problem is that I don't *know* what installation path the user will select,...
14
2008
by: Mat| | last post by:
Hello :-) I am learning XPath, and I am trying to get child nodes of a node whose names do *not* match a given string, e.g : <dummy> <example> <title>Example 1</title> <body>this is an example</body>
2
1179
by: blazingmavrick | last post by:
Hi My problem consits of the following:- i am creating mulitple picturebox's, when the user double clicks on the picture box it opens the opendialog box to load a picture (jpeg only) into the picture box. When they have finished they press a button to save the picture's into certain files called Module1.jpeg, Module2.jpeg and so on. These files are created and saved automatically (i.e. not using the save dialog box). When the whole...
1
1382
by: basestring | last post by:
Hi, I need help for my program. I'm new With PHP but i have programming skills in VB so it's quit easy to understand this language, however. i got my self in some problems that i don't understand. I made a form that should add a record to a database and upload a picture to a databasepictures folder the problems is it doesn't upload the selected file. and $_files vars are empty
5
3086
by: Werner Partner | last post by:
I thought about your suggestion to leave tbales and, instead o, work with css. The problem is, that I still don't know veray much about css, so I have some difficulites to understand css-suggestions and to make little more complex designs by myself. Nevertheless I tried This is the original page:
4
5837
by: =?Utf-8?B?Q2FybGFKYWRl?= | last post by:
Can anyone help me? I need to use picture it 2000 every day and use to use it on Windows XP and had NO problems at all. If I would open up windows explorer i could be in my folder that has all of my picture it files in there, .mix files and even though they were not jpegs etc.. windows explorer would show the thumbnail of all of these projects saved so i could quickly look for something and double click to open. Since installing...
0
9591
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10057
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9869
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8883
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7415
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6676
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5312
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5449
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3575
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.