标题:求窗口问题!goto用法
只看楼主
m2568092
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2010-3-7
结帖率:66.67%
已结贴  问题点数:20 回复次数:8 
求窗口问题!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
gameohyes
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:湖南
等 级:版主
威 望:53
帖 子:1275
专家分:3629
注 册:2009-3-5
得分:0 
if (m == 1 || m == 2) {
                    sum = (m - 1) * 31 + d; }
                   else {}-->去掉既可.
因为一旦m=1或者m=2那么它执行完 sum = (m - 1) * 31 + d; 后。不会再往下执行
if(){}else{}--->如果满足则执行if(){执行这代码}-->(否则)else{执行这}

C#超级群 74862681,欢迎大家的到来!
2010-03-19 23:09
gameohyes
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:湖南
等 级:版主
威 望:53
帖 子:1275
专家分:3629
注 册:2009-3-5
得分:0 
WanNianLi.rar (68.47 KB)


[ 本帖最后由 gameohyes 于 2010-3-19 23:17 编辑 ]

C#超级群 74862681,欢迎大家的到来!
2010-03-19 23:10
gameohyes
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:湖南
等 级:版主
威 望:53
帖 子:1275
专家分:3629
注 册:2009-3-5
得分:0 
你先看下源码。不懂提问。
我先下了.--->最好的解决问题方法:---->调试-->

C#超级群 74862681,欢迎大家的到来!
2010-03-19 23:20
八心
Rank: 2
等 级:论坛游民
帖 子:11
专家分:10
注 册:2009-10-20
得分:0 
时间最好不要让客户去输入,变成可选控制比较好。
2010-03-20 15:03
m2568092
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2010-3-7
得分:0 
回复 4楼 gameohyes
不道德有木马
2010-03-20 19:09
gameohyes
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:湖南
等 级:版主
威 望:53
帖 子:1275
专家分:3629
注 册:2009-3-5
得分:0 
...不知怎么说..................

C#超级群 74862681,欢迎大家的到来!
2010-03-21 18:17
gameohyes
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:湖南
等 级:版主
威 望:53
帖 子:1275
专家分:3629
注 册:2009-3-5
得分:20 
我用的360没报毒。我系统也稳定.
    如你那真报毒,那对不起。
   

[ 本帖最后由 gameohyes 于 2010-3-21 18:22 编辑 ]

C#超级群 74862681,欢迎大家的到来!
2010-03-21 18:18



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-299925-1-1.html




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

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