TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Micheal Zwane
NA
3
1k
I would like to add code for error detection in this code,
Feb 8 2015 8:16 PM
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Programming
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
int days = 1;
while (days <= 31)
{
comboBoxday.Items.Add(days);
days = days + 1;
}
int month = 1;
while (month <= 12)
{
comboBoxmonth.Items.Add(month);
month = month + 1;
}
int year = 1900;
while (year <= 2015)
{
comboBoxyear.Items.Add(year);
year = year + 1;
}
}
private void timer1_Tick(object sender, EventArgs e)
{
textBoxDate.Text = DateTime.Now.ToLongTimeString() + " " + DateTime.Now.ToLongDateString();
}
//String Birthday puts together the comboboxes to produce combined output
private void buttonAge_Click(object sender, EventArgs e)
{
string Todaystring = DateTime.Now.ToLongDateString();
DateTime Todaydate = DateTime.Parse(Todaystring);
string Birthday;
Birthday = comboBoxday.SelectedItem.ToString() + " " + comboBoxmonth.SelectedItem.ToString() + " " + comboBoxyear.SelectedItem.ToString();
DateTime Birthdaydate = DateTime.Parse(Birthday);
TimeSpan dateDiff;
dateDiff = Todaydate.Subtract(Birthdaydate);
MessageBox.Show(textBoxName.Text + " your age in days is: " + dateDiff.Days);
}
}
Reply
Answers (
2
)
How do i write resource file and also be created on xml?
C# WinForms RichTextText Block-Style Selection