I am trying to make a windows form application using Visual Basic 2017. I want to display messaged using a label and a Next Button and a Back Button. Every time the Next Button is click I want the message to update and change to whatever you put in your code already. I was think about using If Else statement but somehow i can not get the message to uupdate passed the first display. Thank you.
The algorithm will follow like a flowchart because there will also be a Yes/No Button which can also change the displayed messages on the label.
Thank you guys for your help.

Dani AI

Generated

— the symptom you describe (label updates only once) almost always comes from reinitialising your messages or your index inside the button handler. Put the message collection and the current index at the Form (class) level so they persist between clicks. is correct to ask for code; below are two compact patterns that cover the common cases: a simple linear Next/Back list, and a small node/history model for Yes/No branching.

A simple, foolproof linear approach:

Public Class Form1
    Private messages As List(Of String)
    Private currentIndex As Integer = 0

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        messages = New List(Of String) From {
            "Welcome",
            "Step 1: Do this",
            "Step 2: Do that",
            "Finished"
        }
        UpdateLabel()
    End Sub

    Private Sub btnNext_Click(sender As Object, e As EventArgs) Handles btnNext.Click
        If currentIndex < messages.Count - 1 Then
            currentIndex += 1
            UpdateLabel()
        End If
    End Sub

    Private Sub btnBack_Click(sender As Object, e As EventArgs) Handles btnBack.Click
        If currentIndex > 0 Then
            currentIndex -= 1
            UpdateLabel()
        End If
    End Sub

    Private Sub UpdateLabel()
        lblMessage.Text = messages(currentIndex)
        btnBack.Enabled = currentIndex > 0
        btnNext.Enabled = currentIndex < messages.Count - 1
    End Sub
End Class

For Yes/No branching use a node/state model plus a history stack so Back returns across branches:

Class Node
    Public Property Text As String
    Public Property YesId As Nullable(Of Integer)
    Public Property NoId As Nullable(Of Integer)
End Class

' In the form:
Private nodes As Dictionary(Of Integer, Node)
Private currentId As Integer
Private history As New Stack(Of Integer)()

Private Sub btnYes_Click(sender As Object, e As EventArgs) Handles btnYes.Click
    Dim n = nodes(currentId)
    If n.YesId.HasValue Then
        history.Push(currentId)
        currentId = n.YesId.Value
        lblMessage.Text = nodes(currentId).Text
    End If
End Sub

Private Sub btnBack_Click(sender As Object, e As EventArgs) Handles btnBack.Click
    If history.Count > 0 Then
        currentId = history.Pop()
        lblMessage.Text = nodes(currentId).Text
    End If
End Sub

Troubleshooting checklist: 1) Make sure currentIndex or currentId is not declared inside the click handler; 2) verify your event handlers are actually wired (use Handles or AddHandler); 3) confirm you update lblMessage.Text after changing the index/state; 4) avoid recreating the messages collection on every click. These fixes address the usual causes of the “only updates once” problem.

Please post your code, so we have a better idea of what you've done so far.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.