Solved

Viewing Multiple Pictures

Posted on 2002-05-26
7
205 Views
Last Modified: 2010-05-02
The following code works very nicely for viewing a picture in a ImageBox but it will not allow repeated clicks of the command button.  I must have to unload the first picture before calling the second picture.How is this done?

Private Sub Command1_Click()
Image1.Picture = LoadPictur("C:\WINDOWS\Desktop\snap.jpg")
End Sub
0
Comment
Question by:BOBH
7 Comments
 
LVL 3

Accepted Solution

by:
SirNick earned 50 total points
ID: 7035551
Hi BOBH

Try
dim holdnum as integer
holdnum = 1
Private Sub Command1_Click()

Image1.Picture = LoadPictur("C:\WINDOWS\Desktop\snap.jpg")
End Sub
0
 
LVL 4

Expert Comment

by:TomLaw1999
ID: 7035552
I just tried it, worked fine for me. Only thing I can see wrong is the spelling, should be LoadPicture.
0
 
LVL 3

Expert Comment

by:SirNick
ID: 7035556
Hi BOBH

Sorry about the above


dim holdnum as integer
holdnum = 1
Private Sub Command1_Click()
  Image1.Picture = LoadPicture("")
if holdnum = "1" then
  Image1.Picture = LoadPicture("C:\WINDOWS\Desktop\snap.jpg")
elseif holdnum = "2" then
  Image1.Picture = LoadPicture("C:\WINDOWS\Desktop\snap2.jpg")
elseif holdnum = "3" then
  Image1.Picture = LoadPicture("C:\WINDOWS\Desktop\snap3.jpg")
end if
holdnum = holdnum + 1
End Sub

Hope this helps...
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 22

Expert Comment

by:rspahitz
ID: 7039797
If you're looking to display a series of pictures in sequence every time you click a button, such as one labeled "Next" there are several ways.  The above comment is one.  Here's another:

' Assumes all desired pictures are in one directory, and all of the same type

' Place this before all other procedures
Private m_strFilename as string

private sub Form_Load()
'...other code here
   InitializePictures
'...other code here
end sub

private sub InitializePictures()
   ' strMyPath is the path to the pictures
   dim strMyPath as string

   strMyPath = "C:\WINDOWS\Desktop\"
   m_strFilename = Dir$(strMyPath & "*.jpg")
end sub

Private sub Command1_Click()
  Image1.Picture = LoadPicture(m_strFilename)
  m_strFilename = Dir$
  if m_strFilename = vbNullString then
    ' out of pictures...start again
    InitializePictures
  end if
end sub
0
 

Author Comment

by:BOBH
ID: 7041669
Finally got back into the forum. I've been locked out for several days for unknown reasons.
 The above comments are excellent, and I will give them a  try.  Basically what I've been trying to do is to retrieve an ever changing JPG picture from another application from the clipboard and show it in an Image box by calling the same file name repeatedly.  The problem has been that the program will run for a while, but then develops an error. Error trapping can eliminate the error but no new pictures are assigned to the Image box. I cannot number each picture as there will be an infinate number of them. Perhaps some of the above comments will help.
                                    73    RSH
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7818573
Hi BOBH,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept SirNick's comment(s) as an answer.

BOBH, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
0
 

Expert Comment

by:SpideyMod
ID: 7909978
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

759 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

18 Experts available now in Live!

Get 1:1 Help Now