Visula Kavinda
Visula Kavinda

Reputation: 3

How to override internal functions?

I want to replace xxxx function in m function in inherit class how can do this here is my code:

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim h As New y5
        h.xxxx()
        h.m()
    End Sub

    Class x
        Friend Sub xxxx()
            MsgBox("JJ")
        End Sub
        Sub m()
            xxxx()
        End Sub
    End Class
    Class y5
        Inherits x
        Friend Sub xxxx()
            MsgBox("KK")
        End Sub
    End Class

Upvotes: 0

Views: 51

Answers (1)

Idle_Mind
Idle_Mind

Reputation: 39122

I ~think~ you want KK to appear when h.m() is executed?...instead of JJ?

If that's the case, then you need overrideable and overrides, like this:

Class x
    Friend Overridable Sub xxxx()
        MsgBox("JJ")
    End Sub
    Sub m()
        xxxx()
    End Sub
End Class
Class y5
    Inherits x
    Friend Overrides Sub xxxx()
        MsgBox("KK")
    End Sub
End Class

Upvotes: 1

Related Questions