EDIT
Given the new information in the OP - another solution to your problem might be to use optional parameters - that is:
Private Shared Sub AAA(Optional ByVal str As String = Nothing)
Also - permission works in the "right" way, if you just change the order of declarations - this avoids the compiler error:
Private Shared Sub AAA(ByVal str As String) End Sub Private Sub AAA() Form1.AAA(Nothing) End Sub
-
Keeping this below, because it may be useful in other circumstances.
Perhaps your larger application did something like this - VB is full of the kind of mess you can get into. This will compile but crash:
Public Class Form1 Private Shared Sub AAA() Form1.Text = "this" End Sub Private Sub Label1_TextChanged(sender As System.Object, _ e As System.EventArgs) _ Handles Label1.TextChanged Form1.AAA() End Sub End Class
The same thing, it is actually "excellent" (I use this term freely) ...
Public Class Form1 Private Shared dont As Boolean = True Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) _ Handles MyBase.Load dont = False End Sub Private Shared Sub AAA() If Not dont Then Form1.Text = "this" End Sub Private Sub Label1_TextChanged(sender As System.Object, _ e As System.EventArgs) _ Handles Label1.TextChanged Form1.AAA() End Sub End Class
This is because the text change handler will fire before Form1 finishes loading (i.e., during InitializeComponent() !) And will refer to the default instance that has not been created yet, so VB is trying to create a new one for so that you can call a generic method that rotates you in an infinite loop.
Oddly enough, the Load handler is "excellent" (again, free) to call Form1.AAA() inside - as in your initial code, because the default instance ( Form1 instance of the Form1 class) is completed at that moment, and the other will not be created to meet the call. Any other code path, however, begins in a common call and ultimately ends up touching any instance data, no matter how the torturous path spins and spins.
See also: Why is there a default instance for each form in VB.Net but not in C #?