hello
I would like to create a subroutine, so that I don't have to repeat the code.

I have different labels on a form in which when the user clicks on them it hides the second form and show the third form

for now I have this code for every labels:

Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label2.Click

  Label2.Text = "part2"
        form2.Close()
        UnitName = "Part2"
        form3.Show()

I have tried and came up with this:

Public Sub UnitSet( ByVal UnitName As string)

        Dim Name As String

        form2.Close()
        'Name = UnitName
        form3.Show()

    End Sub

but it is not working.

A little more detail about what isnt working would be helpful. Also you should properly declare instances of each for you want to create.

Private Sub LoadForm3( )

    Dim frm As New Form3
    frm.Show()

End Sub
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.