新人初来乍到~

嗯,终于开通博客园了,其实早就想开了,不过一直犹豫像这样一个高手云集的地方,我一个学编程没多久的各种菜鸟大学生真的能来吗...不过最近听到某前辈对我说了一句话”想成为高手就是要有被XXOOX的准备呀...“于是来被XOXXO了,请各位多多指教~

由于网站分类那里没有新人问候的选项,所以还是发点实际的东西,

这学期在上C#,不过一直看着那个黑屏白字的是控制台窗口实在是太无聊,所以自学了一下C#的windows窗体

2011041212121167.jpg

 

 
   
1 using System;
2 using System.Collections.Generic;
3 using System.ComponentModel;
4 using System.Data;
5 using System.Drawing;
6 using System.Linq;
7 using System.Text;
8 using System.Windows.Forms;
9
10 namespace MEの窗体02
11 {
12 public partial class Form1 : Form
13 {
14 double a, b, c;
15 bool bo = true ; // 为假就往下算了
16
17 public Form1()
18 {
19 InitializeComponent();
20 this .Text = " 猫の计算器 " ;
21
22 textBox1.Text = " 请输入左运算数 " ;
23 textBox2.Text = " 请输入右运算数 " ;
24 button1.Text = " 喵一下~ " ;
25
26 radioButton1.Checked = true ; // 默认是加法
27 pictureBox1.Load( " F:\\ME!\\MyProjects\\visual studio 2010Projects\\MEの窗体02\\face2.bmp " );
28 pictureBox2.Load( " F:\\ME!\\MyProjects\\visual studio 2010Projects\\MEの窗体02\\23.bmp " );
29 }
30
31 private void button1_Click( object sender, EventArgs e)
32 {
33 bo = true ; // 判断 只有全是数字时才继续执行
34 int d = 0 ; // 记录点号出现次数,只能一次
35 string str1 = "" ,str2 = "" ;
36
37 foreach ( char ch in textBox1.Text)
38 if (ch != ' ' )
39 str1 += ch;
40 textBox1.Text = str1;
41 foreach ( char ch in textBox2.Text)
42 if (ch != ' ' )
43 str2 += ch;
44 textBox2.Text = str2;
45
46 for ( int i = 1 ; i < textBox1.Text.Length; i ++ )
47 {
48 if ( ! (textBox1.Text[ 0 ] == ' + ' || textBox1.Text[ 0 ] == ' - '
49 || ( int )textBox1.Text[ 0 ] - 48 >= 0
50 && ( int )textBox1.Text[ 0 ] - 48 <= 9 ))
51 bo = false ;
52 if (( int )textBox1.Text[i] - 46 >= 0 && ( int )textBox1.Text[i] - 46 <= 11 )
53 {
54 if (textBox1.Text[i] == ' / ' )
55 bo = false ;
56 if (textBox1.Text[i] == ' . ' )
57 {
58 d ++ ;
59 if (d > 1 )
60 bo = false ; // 点号,只能有一个且不能出现在末尾
61 }
62 }
63 else
64 bo = false ;
65 }
66 d = 0 ;
67 for ( int i = 1 ; i < textBox2.Text.Length; i ++ )
68 {
69 if ( ! (textBox2.Text[ 0 ] == ' + ' || textBox2.Text[ 0 ] == ' - '
70 || ( int )textBox2.Text[ 0 ] - 48 >= 0
71 && ( int )textBox2.Text[ 0 ] - 48 <= 9 ))
72 bo = false ;
73 if (( int )textBox2.Text[i] - 46 >= 0 && ( int )textBox2.Text[i] - 46 <= 11 )
74 {
75 if (textBox2.Text[i] == ' / ' )
76 bo = false ;
77 if (textBox2.Text[i] == ' . ' )
78 {
79 d ++ ;
80 if (d > 1 )
81 bo = false ;
82 }
83
84 }
85 else
86 bo = false ;
87 }
88 // -----------------结束判断
89 if (bo == true )
90 {
91 a = double .Parse(textBox1.Text);
92 b = double .Parse(textBox2.Text);
93
94 if (radioButton1.Checked == true )
95 {
96 c = a + b;
97 textBox3.Text = a.ToString() + " + " + b.ToString() + " = " + c.ToString();
98 }
99 if (radioButton2.Checked == true )
100 {
101 c = a - b;
102 textBox3.Text = a.ToString() + " - " + b.ToString() + " = " + c.ToString();
103 }
104 if (radioButton3.Checked == true )
105 {
106 c = a * b;
107 textBox3.Text = a.ToString() + " * " + b.ToString() + " = " + c.ToString();
108 }
109 if (radioButton4.Checked == true )
110 {
111 c = a / b;
112 textBox3.Text = a.ToString() + " / " + b.ToString() + " = " + c.ToString();
113 }
114
115 }
116 else
117 textBox3.Text = " 数字输入都会出错..你是バガ..喵... " ;
118
119 }
120
121
122 private void radioButton1_CheckedChanged( object sender, EventArgs e) { }
123 private void radioButton2_CheckedChanged( object sender, EventArgs e) { }
124 private void textBox1_TextChanged( object sender, EventArgs e) { }
125 private void textBox2_TextChanged( object sender, EventArgs e) { }
126 private void textBox3_TextChanged( object sender, EventArgs e) { }
127 private void radioButton3_CheckedChanged( object sender, EventArgs e) { }
128 private void pictureBox1_Click_1( object sender, EventArgs e) { }
129 private void pictureBox2_Click( object sender, EventArgs e) { }
130
131
132 }
133 }

转载于:https://www.cnblogs.com/dshGame/archive/2011/04/12/2013508.html

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值