0

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.

Edited by __avd: Added [code] tags. For easy readability, always wrap programming code within posts in [code] (code blocks).

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by TomW
0

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
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.