-2
//When clicked on a button on this form this class will show a form to renew the license

private void button1_Click(object sender, EventArgs e)
{
    Notif f = new Notif();
    f.Show();
    int b = 

    //how to get the value from Valid class
}

//This is the class of a form which will display a renew button to renew the license

private void button1_Click(object sender, EventArgs e)
{
    int d = DateTime.Now.Day;
    this.Close();

    //how to pass this date to form1 class...??      

}

//This is the class to capture the value of the day sent from the renew button of the above class

public static  class Valid
{
    public int day { get; set; }

} 

I am seeking the solution for the problem i.e how can I get the value of the day in the Form1 class if the renewed button is clicked..??

You can read the comments mentioned in each of the classes u will understand the problem

Glen Thomas
  • 10,190
  • 5
  • 33
  • 65
  • 2
    I would start with some basic C# training ... `Valid` class would not even compile – Selvin Mar 08 '19 at 09:15
  • Ok then whats the solution for this problem..?? – Abrar Shaikh Mar 08 '19 at 09:17
  • I've also recomend some googling course also ... "passing data between forms in C#" should return bazillions answers – Selvin Mar 08 '19 at 09:20
  • *"how to get the value from `Valid` class"* - make it valid first, then [access static member](https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/static-classes-and-static-class-members) as usual: `Valid.SomeStaticMember`. – Sinatr Mar 08 '19 at 09:46

1 Answers1

0

So you want to send the int d to class Valid and then get it into int b =... ?

public static class Valid
{
     public static int _day; /* if you have setters and getters 
                    with day and you dont want a stack overflow you need _day*/
     public static int day {get{return _day; } set{_day=value;}}
}

This is the class of a form which will display a renew button to renew the license

public int alternative_d;
private void button1_Click(object sender, EventArgs e)
{
     int d = DateTime.Now.Day;
     Valid.day=d; 
     alternative_d=d;
     this.Close();
     //how to pass this date to form1 class...??      
}

When clicked on a button on this form this class will show a form to renew the license

private void button1_Click(object sender, EventArgs e)
{
    Notif f = new Notif();
    f.ShowDialog(); /*<-- use show dialog, your code resumes at next line when f is closed*/
    int b = Valid.day;//how to get the value from Valid class
    int b= f.alternative_d; //either one or the other; no extra class needed
}
Selvin
  • 6,598
  • 3
  • 37
  • 43