2
Contributors
9
Replies
10
Views
5 Years
Discussion Span
Last Post by mazzica1
0

if you mean some thing like (int,string,..) you cannot so can you be accurate and till us what exactlly you want to send you how

0

what I want that if the user click error detection in the button_Click it will check the error array and then print something to the user , so can I pass the error array to this method

0

you donot have to send it just you need to know "error array " where is it declared? and access it from the button_Click

0

i couldn't access it

public Form1()
        {
            
            InitializeComponent();
            Inst firstInst = new Inst();
            bool[] ers = firstInst.getErrArr();
           
        


            firstInst.ErrorDetection();
           ErrMsg( firstInst.getErrArr());

            
        }

if the button_click is defined after this can I access the object firstInst in it??

0

no cause it is scope is the Form1 constructor but you can do this

class Form1
{
Inst firstInst =null;
 public Form1()
 {      
      InitializeComponent();
      firstInst = new Inst();
      bool[] ers = firstInst.getErrArr();
           
      firstInst.ErrorDetection();
      ErrMsg( firstInst.getErrArr());
 }
}

and then use it in button_click as

private void button1_Click(object sender, EventArgs e)
{
      if(firstInst !=null)
      {
         //do something
      }
}
0
//The button1_Click function that called when button click event happend
private void button1_Click(object sender, EventArgs e)
{
      //check that the variable was initialized
      if(firstInst !=null)
      {
         //Add your code here
         //do something
      }
}
0

thanks a lot you've been helping me a lot recently I really appreciate it
Thanks again

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.