标题:请问我这个代码为什么会出现这样的提示:“检测道无法访问的代码”。。秋高 ...
只看楼主
zhongyu
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2013-4-8
结帖率:0
已结贴  问题点数:10 回复次数:1 
请问我这个代码为什么会出现这样的提示:“检测道无法访问的代码”。。秋高手指点
using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication4
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
       // public static string Usrname = "钟宇";
        public static string   Password = "asdf";
        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            
        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {

            if ((textBox1.Text.Trim().Length == 9))
            {
                textBox2.Focus();
            }
        }
      
        public bool checkinput()
        {
             if (textBox1.Text.Trim().Length > 9 && textBox1.Text.Trim ().Length  <= 6 )
            {
                MessageBox.Show("用户名不满足要求","提示");
                return false;               
            }
            
                 if (textBox1.Text.Trim().Length < '0' || textBox1.Text.Trim().Length > '9')
                 {
                     MessageBox.Show("用户名格式错误。", "提示");
                     return false;     
                 }
            
             if (textBox1.Text == "")
             {
                 MessageBox.Show("用户名格式错误。", "提示");
                 return false;
             }
             if (textBox2.Text == "")
             {
                 MessageBox.Show("密码格式错误。", "提示");
                 return false;
             }
             //if ((textBox2.Text != asdf ))
             //{
             //    MessageBox.Show("密码错误。", "提示");
             //    return false;
             //}

            if((textBox1 .Text.Trim ().Length  == 9))
            {
              textBox2.Focus();
            }

            return true ;
            Form2 an = new Form2();
            an.ShowDialog();
         }
    //    if (! checkinput(int))
    //    {
    //        return ;
    //    }
    //    else
    //{
        
         

    }
}
搜索更多相关主题的帖子: static private public 
2013-04-22 15:17
shangsharon
Rank: 9Rank: 9Rank: 9
来 自:湖北武汉
等 级:蜘蛛侠
威 望:7
帖 子:221
专家分:1261
注 册:2012-3-25
得分:10 
return true ;
Form2 an = new Form2();
an.ShowDialog();

第一句代码已经返回,方法执行结束,后面两句代码不会执行的.所以才会有问题中的提示信息.
2013-04-22 20:14



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




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

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