Peter PitLock
Peter PitLock

Reputation: 1873

VB.Net - 2 Classes with same Function Name resulting in same function - Argument not specified for parameter

Public Class Log
        Public Shared Sub Log(p1 as integer, optional p2 as integer)
            Try

            Catch ex As Exception

            End Try
        End Sub
End Class



Public Class ShortCutClass

        Public Shared Sub Log(p1 as integer)
            Try
                Log.Log(p1) '~~~~~~
            Catch ex As Exception

            End Try
        End Sub

End Class



Argument not specified for parameter p1 of 'Public Shared Sub Log(p1 as integer)'

I have a Class called Log, with a Sub Called Log.

Sometimes in the website, ShortCutClass.Log is called - it is existing code and the only place I can make a change is within ShortCutClass.Log

There are many calls to both Log.Log and ShortCutClass.Log

I am getting the error "Argument not specified for parameter p1 of 'Public Shared Sub Log(p1 as integer)'" It is like Log.Log tries to call itself, and then sees that it expects the parameter

How can I call Log.Log from

ShortCutClass.Log

Upvotes: 0

Views: 271

Answers (1)

user11909
user11909

Reputation: 1265

Before Log.Log(p1) you could type the namespace of the project.

Like this: Namespace.Log.Log(p1) (Namespace could be the project name)

And the Optional Parameter should have a default value like this:

Public Shared Sub Log(p1 as integer, Optional p2 as integer = 0)

Upvotes: 1

Related Questions