title: vb6, variable not defined for Label using Module
body: <p>Sorry to ask such a dumb question.. but for the life of me i cant get it.. i have searched EVERYWHERE... This is a Re-Creation of my code that gives the same error. This is the most basic example i could re-create.</p>
  
  <p>I dont understand why i have to declare a Label ?? (or an object)</p>
  
  <p>What I am trying to accomplish is use my main form to call all the modules.</p>
  
  <p>This is the FORM</p>
  
  <pre><code>'frmMain.frm
  Option Explicit
  
  Public Sub btnOpen_Click()
      GetNum
  End Sub
  </code></pre>
  
  <p>This is the MODULE</p>
  
  <pre><code>'modGet.bas
  Option Explicit
  
  Public Sub GetNum()
      Dim a As String
      Dim b As String
  
      a = "hello"
      b = "world"
  -&gt;  Label1.Caption = a    'ERROR, Compile Error, Variable not Defined. (vb6)
      Label2.Caption = b
  End Sub
  </code></pre>
  
  <p>YES, i have a form, with a Button named 'btnOpen', i have 2 Labels named 'Label1' &amp; 'Label2'</p>
  
  <p>If i ADD.. </p>
  
  <pre><code>Dim Label1 As Object  'in MODULE
  </code></pre>
  
  <p>i get a different error..
  ERROR '91' Object Variable or With block variable not set</p>
  
  <p>IF I put everything in 1 FORM, it works..(but i want to use separate modules)
  I Commented out 'OPTION EXPLICIT' ... same error.</p>
  
  <p>In another Test, i got the error for a TextBox..</p>
  
  <pre><code>TextBox1.Text = x
  </code></pre>
  
  <p>Once i get the answer for this, i can apply it for everything... I'm sure it's simple too and imma feel stupid. :-(</p>
  
  <p>One of my Main Things is Querying WMI, and i get the ERROR '91' for the Label (This is in a For Each Loop) .. But its the same error, its like its makin me Declare Objects..(using Modules)</p>
  
  <pre><code>Label1.Caption = objItem.Antecedent
  </code></pre>
  
  <p>If Someone Could PLEASE Help me...</p>