?
Solved

Viewing Multiple Pictures

Posted on 2002-05-26
7
Medium Priority
?
214 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
[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
7 Comments
 
LVL 3

Accepted Solution

by:
SirNick earned 200 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses

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