| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1099 人关注过本帖
标题:求窗口问题!goto用法
取消只看楼主 加入收藏
m2568092
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2010-3-7
结帖率:66.67%
收藏
已结贴  问题点数:20 回复次数:2 
求窗口问题!goto用法
using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WanNianLi
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void btnJiSuan_Click(object sender, EventArgs e)
        {
            int y, m, d, sum;
            y = int.Parse(txtYear.Text);
            m = int.Parse(txtMonth.Text);
            d = int.Parse(txtDays.Text);
                                                                        
            if (y < 1 || y > 9999)
            {
                txtXianShi.Text = "你输入的年份不正确!请重新输入!";
                txtYear.Text = "";
                txtYear.Focus();
               }
                else if (m < 1 || m > 12)
                {
                txtXianShi.Text = "你输入的月份不正确!请重新输入!";
                txtMonth.Text = "";
                txtMonth.Focus();
               
                }
                else {
                     switch (m) {
                        case 2:
                            if ((y % 100 != 0 && y % 4 == 0) || (y % 400 == 0)) {
                                if (d < 1 || d > 29) {
                                    txtXianShi.Text = "你输入的天数不正确!请重新输入!";
                                    txtDays.Text = "";
                                    txtDays.Focus();
                           
                            }
                        } break;
                         case 4:case 6:case 9:case 11:
                             if (d < 1 || d > 30) {
                                 txtXianShi.Text = "";
                                 txtDays.Text = "";
                                 txtDays.Focus();
                             
                             } break;
                         default:
                             if (d < 1 || d > 31) {
                                txtXianShi.Text = "你输入的天数不正确!请重新输入!";
                                 txtDays.Text = "";
                                 txtDays.Focus();
                              
                             }
                             break;
                }
                if (m == 1 || m == 2) {
                    sum = (m - 1) * 31 + d; }
                    else {
                        switch (m) {
                            case 9:case 11:
                                sum = (m - 1) * 30 + d - 2 + m / 2 + 1;
                                break;
                            default:
                                sum = (m - 1) * 30 + d - 2 + m / 2;
                                break;
                        } if ((y % 100 != 0 && y % 4 == 0) || (y % 400 == 0)) {
                            sum = sum + 1;
                           }
                           txtXianShi.Text = y + "年" + m + "月" + d + "日是" + y + "年的第" + sum + "天";
                    }
                    
            }

        }
    }
}
WanNianLi.rar (33.12 KB)
goto方法不会用,知道怎么用,还有其他更好的办法来
搜索更多相关主题的帖子: goto 窗口 用法 
2010-03-19 20:11
m2568092
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2010-3-7
收藏
得分:0 
1月和2月不对应显示输出txtXianShi.Text = y + "年" + m + "月" + d + "日是" + y + "年的第" + sum + "天";
2010-03-19 21:31
m2568092
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2010-3-7
收藏
得分:0 
回复 4楼 gameohyes
不道德有木马
2010-03-20 19:09
快速回复:求窗口问题!goto用法
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.053303 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved