title: How to use variable after button click
body: <p>I'm stuck with my program. I have this part of the code:</p>
  
  <pre><code> public void PacketArrival(ref IntPtr ContextHandle, ref int Cursor_Renamed,
              ref int X , ref int Y , ref int Z, ref int Buttons, 
              ref int Pressure , ref int TangentPressure, ref int Azimuth, 
              ref int Altitude, ref int Twist, ref int Pitch , ref int Roll ,
              ref int Yaw,ref int PacketSerial, ref int PacketTim) 
   {   
       tmpl = System.Math.Abs(X);
  
       if( tmpl != prgX.Value)
       {
         if( tmpl &lt;= prgX.Maximum )
            prgX.Value = tmpl;
       }
       tmpl = System.Math.Abs(Y);
       if( tmpl != prgY.Value)
       {
         if( tmpl &lt;= prgY.Maximum)
           prgY.Value = tmpl;
       }
       tmpl = System.Math.Abs(Z);
       if( tmpl != prgZ.Value)
       {
         if( tmpl &lt;= prgZ.Maximum)
           prgZ.Value = tmpl;
       }
       tmpl = System.Math.Abs(Pressure);
       if( tmpl != prgPressure.Value)
          prgPressure.Value = tmpl;
  
       if( Convert.ToInt32(lblX.Text)!= X )
          lblX.Text = X.ToString();
       if( Convert.ToInt32(lblY.Text)!= Y )
          lblY.Text = Y.ToString();
       if( Convert.ToInt32(lblZ.Text)!= Z )
          lblZ.Text = Z.ToString();
       if( Convert.ToInt32(lblPressure.Text)!= Pressure )
          lblPressure.Text = Pressure.ToString();
  
      if (Pressure !=0)
      {
          File.AppendAllText("test2.txt", Pressure.ToString() + Environment.NewLine);               
      }
  
      label1.Text = Pressure.ToString();
  
  }
  </code></pre>
  
  <p>So I wanna use Pressure when I do button click</p>
  
  <pre><code>private void button2_Click(object sender, EventArgs e) 
  {
      label5.text = Pressure.ToString();
  }
  </code></pre>
  
  <p>But I always get 0 as value. Sorry on my english
  Pressure only appears in first part of the code, nowhere else. As you can see, Pressure is also written in the file, but when I want to use it after button click it always shows 0</p>
  
  <p>p.s. label1 shows correct value</p>