views:

20

answers:

1

Hey all, i am in the middle of trying to figure out how to go about doing this...

I have a form that i call like so:

 call frmSlideShow.showWhat("1,4,8,9,11,22")

Each of the numbers represents a different image slide (slide1.png, slide4.png, etc..). The problem i am having is trying to create a "previous" and "next" button to flip through them all. Trying to figure out what number the user is on and going from there and seeing what numbers are still left from the list above that was sent, etc.

If anyone has an idea how i would go about doing that then that would be awesome! :)

UPDATE

here is the code..

Public Sub showWhat(ByVal theNumbers As String)
    Dim theNums As String() = theNumbers.Split(New Char() {","c})
    Dim theCurNum As String

    For Each theCurNum In theNums
        Debug.Print(theCurNum)
    Next
End Sub

David

+2  A: 

Put theNums string array one level up in your code along with an integer variable that keeps track of the current position in the array. Then your next button would check the upperbounds of theNums array to make sure you weren't on the last one. If you weren't, then it would increase the integer variable by one and then you could theNums(intTracker).

Public Class Form1
    Dim theNums As String()
    Dim intTracker As Integer = 0
    Public Sub showWhat(ByVal theNumbers As String)
        theNums = theNumbers.Split(New Char() {","c})
        intTracker = 0
        MsgBox("Currently showing " & theNums(intTracker))
        If theNums.GetUpperBound(0) < 1 Then
            btnNext.Enabled = False 'Only one number was passed, so disable the next button
        End If
    End Sub
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Call showWhat("1,2,3")
    End Sub
    Private Sub btnLast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLast.Click
        btnNext.Enabled = True
        intTracker -= 1
        MsgBox("Now on " & theNums(intTracker))
        If intTracker = 0 Then
            btnLast.Enabled = False 'Disable the button because you're at the beginning
        End If
    End Sub

    Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click
        btnLast.Enabled = True
        intTracker += 1
        MsgBox("Now on " & theNums(intTracker))
        If theNums.GetUpperBound(0) = intTracker Then
            btnNext.Enabled = False 'On the last slide, so disable the next button
        End If
    End Sub
End Class
DaMartyr
awesome, thanks! :o)
StealthRT