计算闰年_winform
2015-12-14 20:54
435 查看
新建窗体应用程序(如下),新建控件label1,label2,label3,textBOX1,button1,button2
label1的Text属性改为“计算闰年演示”
label2的Text属性改为“输入年份”
button1的Text属性改为“确定”
button1的Text属性改为“退出”
完整代码:
label1的Text属性改为“计算闰年演示”
label2的Text属性改为“输入年份”
button1的Text属性改为“确定”
button1的Text属性改为“退出”
完整代码:
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 计算闰年_窗体 { public partial class Form1 : Form { //闰年:能被4整除,但不能被100整除或者能被400整除的年份 public Form1() { InitializeComponent(); } private void button2_Click(object sender, EventArgs e)//退出按钮代码 { Application.Exit(); } private void button1_Click(object sender, EventArgs e)//确定按钮代码 { try { int year = Convert.ToInt32(textBox1.Text); if (year % 400 == 0 || year % 4 == 0 && year % 100 != 0)//闰年:能被4整除,但不能被100整除或者能被400整除的年份 { label3.Text = string.Format("{0}是闰年", year);//输出显示闰年 } else { label3.Text = string.Format("{0}不是闰年", year);//输出显示非闰年 } } catch { MessageBox.Show("请输入正确年份"); } } } }
相关文章推荐
- 浏览器-08 chromium 渲染2
- MyBatis 插入空值时,需要指定JdbcType
- Codeforces Round #335 (Div. 2) A.Magic Spheres
- 在Hyper-V vNext中使用检查点
- 依赖注入的javascript实现
- 注册验证码校验思路
- #三分法判断单峰函数最值#附加例题LA 5009
- 判断字符串里面的左右自负是否被+包围
- App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure.
- ubuntu14 简单安装ffmpeg
- Cocos3D专题课程源码地址
- 自定义View步骤
- GPU(CUDA)学习日记(九)------ CUDA存储器模型
- Android:SystemClock 随记
- 数据结构实验之查找一:二叉排序树【OJ--3373】
- 使用vs调试unity脚本的方法
- 《剑指offer》——孩子们的游戏(圆圈中最后剩下的数)
- 第七次作业+梦飞扬
- instanceof 运算符
- 九度oj 1181 升序链表