title: WPF VB.net sharing public sub procedures
body: <p>I'm new to VB.net so please understand. I have a <code>MainWindow, Frame1, Frame2 (AdFrame1), Page1.</code></p>
  
  <p><code>MainWindow</code> loads <code>Page1</code> from <code>Frame1</code> on startup. In <code>MainWindow.vb class</code> I have a Public Sub that makes <code>Frame2</code> visible.</p>
  
  <p>How would I share that Public Sub so I could use Page_Mouseup Event to show Frame2 (AdFrame1)</p>
  
  <p>I tried Public Shared Sub, but I get this error: "Cannot refer to an instance member of a class from within a shared method or shared member initializer without an explicit instance of the class"</p>
  
  <p>Code in MainWindow.vb: </p>
  
  <pre><code>Private Sub MainWindow2_MouseUp(ByVal sender As Object, ByVal e As MouseEventArgs) Handles Me.MouseUp
  
  
          AdClick()
  
      End Sub
  
  
  
      Public Sub AdClick()
  
  
  
          Try
  
  
              clicks += 1
  
              If clicks &gt;= 10 Then
  
                  'After 5 seconds Adframe CloseLink and TextBlock1 will hide.
                  AdFrame1.Visibility = Windows.Visibility.Visible
                  CloseMainButton.Visibility = Windows.Visibility.Visible
                  InitializeComponent()
                  dpTimer = New DispatcherTimer
                  dpTimer.Interval = TimeSpan.FromMilliseconds(10000)
                  AddHandler dpTimer.Tick, AddressOf TickMe
                  dpTimer.Start()
  
                  clicks = 0
  
              End If
          Catch ex As Exception
              MessageBox.Show("Oops! Error X0123A1. Please contact us with error ASAP!", "Error!", MessageBoxButton.OK)
          End Try
      End Sub
  
  
      'After 10 sesonds auto close
      Private Sub TickMe()
  
          AdFrame1.Visibility = Windows.Visibility.Hidden
  
      End Sub
  </code></pre>
  
  <p>Code Page1.vb</p>
  
  <pre><code>  Private Sub Page1_MouseUp(ByVal sender As Object, ByVal e As MouseEventArgs) Handles Me.MouseUp
  
  
              AdClick() (inaccessible due to protection)
  
          End Sub
  </code></pre>
  
  <p>So how would share AdClick() with Page1</p>