I personally would create a List<Of Panel>
and add the Panels to it. Then use a integer and increment it between 0 to 4, using BringToFront
to show the Current Panel. Something like this.
Public Class Form1
Dim myPanels As List(Of Panel) = New List(Of Panel)
Dim count As Integer = 0
Private Sub btnCancel_Click(sender As System.Object, e As System.EventArgs) Handles btnCancel.Click
count = 0
myPanels(count).BringToFront()
End Sub
Private Sub btnNext_Click(sender As System.Object, e As System.EventArgs) Handles btnNext.Click
If count < 4 Then
count += 1
Else
count = 0
End If
myPanels(count).BringToFront()
End Sub
Private Sub bntPrevious_Click(sender As System.Object, e As System.EventArgs) Handles btnPrevious.Click
If count > 0 Then
count -= 1
Else
count = 4
End If
myPanels(count).BringToFront()
End Sub
Public Sub New()
' This call is required by the designer.
InitializeComponent()
myPanels.Add(Panel1)
myPanels.Add(Panel2)
myPanels.Add(Panel3)
myPanels.Add(Panel4)
myPanels.Add(Panel5)
myPanels(count).BringToFront()
End Sub
End Class