C# 硬盘分区计算器

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication1
{
public partial class Form1 : Form
{

    int M=0;
    public Form1()
    {
        InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {
      
    }

 
    private void label1_Click(object sender, EventArgs e)
    {

    }

   

    private void button1_Click(object sender, EventArgs e)//计算由G转化为M的NTFS格式
    {
        int mm = 0;
        double ZhuMian = 7.84423828125;
        try
        {
            mm = int.Parse(this.textBox1.Text.ToString());
        }
        catch{
            MessageBox.Show(mm + "为一个不合法字符,请输入一个数字!");
            this.textBox1.Focus();
            this.textBox1.Clear();
            return;
        }   
        float SRF = (float)mm;

        double a = SRF * 1024 / ZhuMian;
      //  Double D1 = new Double(a);
        int D= (int)a;
        double zui = 0.0;
        zui = a / D;
        if (zui >= 0.5)
        {
            D++;
        }

        double c = D * ZhuMian;

        M = (int)c;
        double mzui = c / M;
        if (mzui >= 0.5)
        {
            M++;
        }
        this.textBox3.Text=M.ToString();
    }
    private void button2_Click(object sender, EventArgs e)
    {
        int cc=0;
        try
        {
            cc = int.Parse(this.textBox2.Text.ToString());
         
        }
        catch {
            MessageBox.Show(cc + "为一个不合法字符,请输入一个数字!");
            this.textBox2.Focus();
            this.textBox2.Clear();
            return;
       
        }

        float SRN =(float)cc;
        
        double MN = (SRN - 1) * 4 + 1024 * SRN;
        this.textBox4.Text = MN.ToString();
    }

    private void textBox2_TextChanged(object sender, EventArgs e)
    {
        String text2 = this.textBox2.Text.ToString();
       if(!text2.Equals("")){
        this.button2.Enabled=true;
    }
    else if (text2.Equals(""))
    {
        return;
      
       }

        try {
            int text22 = int.Parse(text2);
           
          }catch{              
          MessageBox.Show(text2 + "为一个不合法字符,请输入一个数字!");
          this.textBox2.Focus();
           this.textBox2.Clear();
              return;
          }
    }

    private void label3_Click(object sender, EventArgs e)
    {

    }

    private void textBox1_TextChanged(object sender, EventArgs e)
    {
        String text = this.textBox1.Text.ToString();
        if (!text.Equals("")) {
           this.button1.Enabled=true;
       }
       else if (text.Equals("")) {
           return;
      
       }
        try
        {
            int h = int.Parse(text);

          
        }
        catch{
            MessageBox.Show(text+"为一个不合法字符,请输入一个数字!");
            this.textBox1.Focus();
            this.textBox1.Clear();
            return;
           
        }

    }

    private void clear(object sender, MouseEventArgs e)
    {
       this.textBox1.Clear();
       this.textBox3.Clear();
       return;
    }

    private void clear2(object sender, MouseEventArgs e)
    {
        this.textBox2.Clear();
        this.textBox4.Clear();
        return;
    }

  
   


}
}

 

------------------------------------------------

我的第一个C#小程序,哈哈~~~

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值