[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Moving NEXT or Previous by a CommandButton

Posted on 1999-12-11
3
Medium Priority
?
135 Views
Last Modified: 2010-05-02
In a form, in VB4, I have DriveListBox, a DirListBox and a FileListBox in
which there is a list of some jpg pictures. Making a click in any of these, the picture is
displayed in a pictureBox.
What I ask for is:
I would like to add 2 CommandButtons. One for the next picture of the list and one for the previous.
How could I do it? What is the code for these Buttons?
0
Comment
Question by:ote
3 Comments
 
LVL 12

Expert Comment

by:mark2150
ID: 2274361
Myself, I'd get rid of all the of list boxes and go to the common dialog control. They specify a directory and then read all of the .JPG files into a regular list. Once the list is established moving thru it is easy. With the drive list boxes and such the choices are *displayed* in the control but the results are not easy to interpret nor is it easy to move thru the selections.

M
0
 
LVL 14

Expert Comment

by:mcrider
ID: 2274371
See the EE Thread:

   http://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=10230534

This solution should work for you... It costs 10 points...


Cheers!
0
 
LVL 32

Accepted Solution

by:
Erick37 earned 400 total points
ID: 2274462
Code example:

Option Explicit

Private Sub cmdDown_Click()
    Dim ndx As Integer
    'scroll one line up
    ndx = File1.ListIndex
    If ndx = File1.ListCount - 1 Then Exit Sub 'Bottom
    File1.ListIndex = ndx + 1
    'Update filename
    Debug.Print File1.filename
End Sub

Private Sub cmdUp_Click()
    Dim ndx As Integer
    'scroll one line up
    ndx = File1.ListIndex
    If ndx <= 0 Then Exit Sub 'Top
    File1.ListIndex = ndx - 1
    'Update filename
    Debug.Print File1.filename
End Sub
0

Featured Post

Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

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…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…

612 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