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"
        UnitName = "Part2"

I have tried and came up with this:

Public Sub UnitSet( ByVal UnitName As string)

        Dim Name As String

        'Name = UnitName

    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

End Sub