C#/c#

Advertisement


Question
hiiiiii
i made a gui form which have three lables, three text box and a buton
n i have to ask user to enter his name, age, DOB
if the detail is right then open a form 2
but if the details r wrong, i wana to restrict user to enter the detail only just three times after third, the form should be closed n after first wrong there should b a warning n after second there shud b a warning
plz help me........
and i m atul arora's friend, he recomeded me to go here
and  

Answer
you need to define a public variable for checking the users, each time the user click on button and the information are wrong then add this variable
for date you can use datetimepicker then you do not need to check it out because your user should choose from the valid date just you can set the limitation for range of dates to be shown in that.
for age you can use the following code
 int counter;
       private void button1_Click(object sender, EventArgs e)
       {
           if (counter < 3)
           {
               try
               {
                   if (textBox1.Text.Trim() == "")
                   {
                       MessageBox.Show("Please enter name");
                       return;
                   }
                   if (Convert.ToInt32(textBox2.Text) < 0 || Convert.ToInt32(textBox2.Text) > 99)
                   {
                       counter++;
                       MessageBox.Show("Please enter your age correctly");
                       return;
                   }

               }
               catch
               {
                   counter++;
                   MessageBox.Show("Please enter your age correctly");
               }
           }
           else
               MessageBox.Show("sorry you cannot try more!");

       }

       private void Form2_Load(object sender, EventArgs e)
       {
           counter = 0;
       }

C#

All Answers


Answers by Expert:


Ask Experts

Volunteer


Hosnieh [Sara]

Expertise

Questions which I can answers: 1- Programming (C#.net, Vb.net, javascript, HTML) more Web applications 2- CSS 3-Databases (Ms SQL server -all versions) 4-OS (workstation and servers (windows)) 5- MS office 6- General problems in computer software I cannot answer other kinds of questions which I did not mention here.

Experience

my CV: http://iran-americamarket.com/Contact.aspx I have more than 8 years Experience in IT field. my core skills are : • Asp.net Developer (Portal, Dynamic websites ,e-commercial websites) • Visual studio.net 2003,2005,2008 (VB.net , C#.net , AJAX.net) • O.O programming (n-tier Architecture) • Database (SQL server 2000-2005, Oracle9i, Ms Access) , TSQL, Stored procedures, Triggers • IIS 5-6 , SSL (Installation and configuration SSL) , Network(TCP/IP ,Active directory , DHCP, … ), Windows 2000-2003 Server Configuration and administration • UML (usecase diagram, class diagram) , Microsoft Project • Graphics Design( Photoshop , Flash ) • JavaScript , CSS, DHTML, XML • Hardware (physical installation, configuration , and driver installation) • Ms Office all versions (Ms word, Ms Access, Ms Excel, Ms Outlook , Ms FrontPage, and etc) • OS (Windows –Linux) and VMware • Network Monitoring (Solarwinds) • Computer Teacher, English Teacher • MATLAB (simulations and computation projects)

Organizations
-

Publications
Translation Experience English to Farsi • Use brain scan to predict when people will buy products . May 2008 (Published in AI Magazine) – Medicine , AI • Totally tubular motors _Tomorrow automation technology : March 2008 (Published in AI Magazine) – AI , Mechanic, Industry • Improving PLC compatibility and function flexibility: March 2008 (Published in AI Magazine) – AI , Robotics , Industry • Make packaging lines more flexible: January 2008 (Published in AI Magazine) – AI , Robotics , Industry • Personal CNC : December 2007 (Published in AI Magazine) – AI , Medical , Industry • Multipurpose optical tools Characterize as MEMS: December 2007 (Published in AI Magazine)- optical physics • Managing Innovation: November 2007 (Published in AI Magazine) – IT Management • Calculating the total value of ownership (TVO):October 2007 (Published in San-ate Hooshmand Magazine) -IT and Economics

Education/Credentials
I am currently student and doing my Master in Computer Network Engineering

Awards and Honors
- Poster about new methods of management in Organization( Entrepreneurship ) - 2007

Past/Present Clients
-

©2012 About.com, a part of The New York Times Company. All rights reserved.