Solved

Viewing Multiple Pictures

Posted on 2002-05-26
7
209 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
Technology Partners: 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

Technology Partners: 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!

Question has a verified solution.

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

Suggested Solutions

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

685 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