Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Viewing Multiple Pictures

Posted on 2002-05-26
7
Medium Priority
?
218 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 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
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.

 
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

577 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