0

I try to apply SkinSoft.VisualStyler.ApplyExcludeTag(control As Control, childControls As Boolean) method to Tab Control to disable Skin for this control as below code:

Private Sub MaintenanceProgramForm_Load(sender As Object, e As EventArgs) 
    vssfVisualStyler.ApplyExcludeTag(FormClientsAndSites.tabClientsAndSites, False)
    'Some Code
End Sub

I received this warning:

BC42025: Access of shared member, constant member, enum member or nested type through an instance; qualifying expression will not be evaluated.

How can I disable this warning?

Ferekikoo
  • 23
  • 5

1 Answers1

1

The warning occurs just to inform you that the ApplyExcludeTag() method is shared and thus doesn't need an instance of its containing class in order to be called.

Just call it on the class directly:

VisualStyler.ApplyExcludeTag(FormClientsAndSites.tabClientsAndSites, False)

EXPLANATION

Since you seem to be unaware of how Shared members work, here's a brief explanation:

Marking something as Shared makes it so that you don't need a specific instance in order to access a method, field or property of that type.

For example, instance methods work like this:

Public Class SomeClass
    Public Sub SayHello()
        MessageBox.Show("Hello World!")
    End Sub 
End Class

In order to call this you first need to initialize an instance of the SomeClass class:

Dim cls As New SomeClass
cls.SayHello() 'Opens a message box that says "Hello World!".

However, when marking a method as Shared you no longer need to create an instance before being able to call it:

Public Class SomeClass
    Public Shared Sub SayHello()
        MessageBox.Show("Hello World!")
    End Sub 
End Class
SomeClass.SayHello() 'Opens a message box that says "Hello World!".

Based on the warning you got, we know that ApplyExcludeTag() is marked as Shared.

Visual Vincent
  • 18,045
  • 5
  • 28
  • 75
  • Is there a way to disable this Warning? – Ferekikoo Aug 15 '19 at 11:26
  • Yes there is, but why would you need to? By calling the method on the class instead like I explained in my answer the warning will disappear. Or is there a specific reason you prefer to call it via your variable over calling it directly on the class? – Visual Vincent Aug 15 '19 at 12:46
  • Would you please show me how to call it on the class while I'm new in VB.net? – Ferekikoo Aug 15 '19 at 12:50
  • @Ferekikoo : I updated my answer to include a brief explanation about how shared methods work compared to regular instance methods. I hope it'll help you get a better understanding on what the differences are and why you needed to call `ApplyExcludeTag()` that way. – Visual Vincent Aug 15 '19 at 13:06
  • @Ferekikoo : If my answer solved your problem please don't forget to mark it as accepted (can be done by pressing the tick/check mark on its left). If you still feel you don't understand or if you have other questions regarding the matter I'd be happy to answer them. – Visual Vincent Aug 16 '19 at 09:03
  • That Now I know how it works :), I tried to vote but unfortunately my reputation is less that 15, Thanks Again – Ferekikoo Aug 16 '19 at 20:26
  • @Ferekikoo : Glad I could help! – Visual Vincent Aug 17 '19 at 00:59