using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string runKey = "SOFTWARE\\myapp";
Microsoft.Win32.RegistryKey mykey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(runKey,true);
string days = textBox1.Text;
int c = Convert.ToInt32(textBox1.Text);
if (c <= 30)
{
mykey.SetValue("Name", days);
label1.Text = "Added";
}
else
{
textBox1.Text = "Enter < 30 days";
label1.Text = "";
}
}
}
}
Explanation:
If your i/p above 30 only it will accept otherwise show alert.