title: VB .net: How to disable/enable buttons depends who's logged in (admin account vs. ordinary account)
body: <p>I'm almost done with my project and just asked my teacher for an extension. By the way, here's the last problem that I've been trying to figure out.
  <br>
  <br>
  So what I would like to do is that when "admin" is logged in, the "ADD" and "REMOVE" buttons are enabled or shown from the other form. So this is how my login form looks like: 
  <br>
  <br></p>
  
  <pre><code>Public Class LoginForm
  
  Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
  
      Me.Show()
      UsernameTextBox.Focus()
      AcceptButton = LoginButton
  
  End Sub
  
  
  Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles LoginButton.Click
  
      Dim login = LoginTableAdapter.UserPasswordString(UsernameTextBox.Text, PassTextBox.Text)
  
      If login Is Nothing Then
          MsgBox("Username and Password did not match.", MsgBoxStyle.Critical)
          UsernameTextBox.Text = ""
          PassTextBox.Text = ""
          UsernameTextBox.Focus()
  
      Else
          MsgBox("Welcome!", MsgBoxStyle.Information)
          Me.Hide()
          SearchForm.Show()
  
      End If
  
  End Sub
  
  
  Private Sub ExitButton_Click(sender As System.Object, e As System.EventArgs) Handles ExitButton.Click
      End
  
  End Sub
  
  Private Sub UsernameTextBox_TextChanged(sender As System.Object, e As System.EventArgs) Handles UsernameTextBox.TextChanged
  
  End Sub
  End Class
  </code></pre>
  
  <p><br>
  So all of my users are connected to my MS Access database. But what I would like to do is that whenever "admin" and "1234" (as password) were logged in, the "ADD" and "Remove" buttons will enable but for example I logged in "userme" and "1234" (as password) the buttons will disappear or disable. Guys, plea se bear with me and thank you.</p>
  
  <p><strong>BEST ANSWER:</strong>
  <br>
  <br>
  <br></p>
  
  <p>So thank you so much guys for sharing your answers. So this is the code that I used and it doesn't matter where you wanna put it, either to your Login form or to the second form. I actually put it inside a timer and it worked flawlessly.</p>
  
  <pre><code>     Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
  
      If LoginForm.UsernameTextBox.Text = "admin" Then
          RemoveButton.Visible = True
          AddButton.Visible = True
  
      Else
          RemoveButton.Visible = False
          AddButton.Visible = False
  
      End If
     End Sub
  </code></pre>