title: Switching between forms (VB.NET)
body: <p>I always get an exception when I try to switch between different forms in my program. Maybe you will help me to solve this issue. Here is the exception message:</p>
  
  <p><em>Control.Invoke must be used to interact with controls created on a separate thread</em></p>
  
  <p>I have attached the forms to very nice variables and this problem occurs when I try to use command like MyForm.Show().</p>
  
  <p>It does not happen when the forms are not attached to variables, but then I have collosal problems with refreshing the textboxes and stuff.</p>
  
  <p>Hope to hear you soon!</p>
  
  <hr>
  
  <p>edit;</p>
  
  <p>I have 4 different forms. When I load the main module and main form, in the Sub (...) Handles MyBase.Load I execute the following code:</p>
  
  <p>In module:</p>
  
  <pre><code>Public StartupForm As frmStartup
  Public RegularForm As frmRegularUse
  Public LoginForm As frmLogin
  Public PasswordForm As frmPassword
  Public SettingsForm As frmSettings
  </code></pre>
  
  <p>In main form:</p>
  
  <pre><code>RegularForm = Me
  StartupForm = frmStartup
  LoginForm = frmLogin
  PasswordForm = frmPassword
  SettingsForm = frmSettings
  </code></pre>
  
  <p>This is the aproach I worked out to get the full control over refreshing the forms. It is a program for Motorola Scanner with Windows CE. Now, for example, when I enter the correct password in LoginForm, I want to switch to the RegularForm. When I try to use RegularForm.Show() or RegularForm.ShowDialog or RegularForm.BringToFront(), I get an exception. When I try to call the form with the frmRegularUse.Show() I can call the form, but it is being created in a different thread, I believe, so I loose control over it (when I try to put something from the keyboard, there is no response).</p>