




下載本文檔
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
1、實驗五/六:Windows界面設(shè)計基礎(chǔ)一、實驗?zāi)康氖煜indows窗體及其各種基本控件的功能和用法二、實驗內(nèi)容利用Windows窗體及其各種基本控件實現(xiàn)簡易計算器。三、實驗組織運(yùn)行要求編寫的源程序要立即上機(jī)編譯運(yùn)行來檢驗程序中存在的問題。通過運(yùn)行的結(jié)果驗證程序的功能是否實現(xiàn)。有一些系統(tǒng)類的方法、變量也需要上機(jī)實驗去了解它們的含義。四、實驗條件Windows XP, Visual Studio 2005五、實驗步驟using System;using System.Collections.Generic;using System.ComponentModel;using System.Data
2、;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace 學(xué)友計算器 public partial class Form1 : Form public Form1() InitializeComponent(); private string fh = "" private string first = "" private void button1_Click(object sender, EventArgs e) tex
3、tBox1.Text = textBox1.Text+ "1" private void button2_Click(object sender, EventArgs e) textBox1.Text = textBox1.Text + "2" private void button3_Click(object sender, EventArgs e) textBox1.Text = textBox1.Text + "3" private void button4_Click(object sender, EventArgs e) t
4、extBox1.Text = textBox1.Text + "4" private void button5_Click(object sender, EventArgs e) textBox1.Text = textBox1.Text + "5" private void button6_Click(object sender, EventArgs e) textBox1.Text = textBox1.Text + "6" private void button7_Click(object sender, EventArgs e
5、) textBox1.Text = textBox1.Text + "7" private void button8_Click(object sender, EventArgs e) textBox1.Text = textBox1.Text + "8" private void button9_Click(object sender, EventArgs e) textBox1.Text = textBox1.Text + "9" private void button10_Click(object sender, EventAr
6、gs e) textBox1.Text = textBox1.Text + "0" private void buttondot_Click(object sender, EventArgs e) if (textBox1.Text.IndexOf(".") < 0) textBox1.Text += "." /如果textBox1中的“.”個數(shù)小于0(即沒有),則在數(shù)后面加一個“.” else /如果textBox1中有了一個以上的“.”,則什么也不做 private void buttonFs_Click(object se
7、nder, EventArgs e) /表示正負(fù)數(shù) textBox1.Text = Convert.ToString(Convert .ToDouble (this.textBox1.Text) * -1); private void buttonbs_Click(object sender, EventArgs e) /退格 if (textBox1.Text = "") textBox1.Text = "" else textBox1.Text = textBox1.Text.Substring(0, textBox1.Text.Length - 1
8、); private void buttonClear_Click(object sender, EventArgs e) textBox1.Text = "" private void buttonAdd_Click(object sender, EventArgs e) first = textBox1.Text; textBox1.Text = "" fh = "+" private void buttonsub_Click(object sender, EventArgs e) first = textBox1.Text; t
9、extBox1.Text = "" fh = "-" private void buttonMul_Click(object sender, EventArgs e) first = textBox1.Text; textBox1.Text = "" fh = "*" private void buttonDis_Click(object sender, EventArgs e) first = textBox1.Text; textBox1.Text = "" fh = "/&quo
10、t; private void buttonQy_Click(object sender, EventArgs e) first = textBox1.Text; textBox1.Text = "" fh = "%" private void buttonx2_Click(object sender, EventArgs e) if (textBox1.Text = "") textBox1.Text = "" else first = textBox1.Text; textBox1.Text = Convert
11、.ToString(Convert.ToDouble(textBox1.Text) * Convert.ToDouble(textBox1.Text); private void buttonsqrt_Click(object sender, EventArgs e) if (textBox1.Text = "") textBox1.Text = "" else first = textBox1.Text; if (Convert.ToDouble(first) < 0) MessageBox.Show("開平方根的數(shù)不能小于0,請重新輸
12、入", "錯誤", MessageBoxButtons.OK, MessageBoxIcon.Error); else textBox1.Text = Convert.ToString(Math.Sqrt(Convert.ToDouble(first); private void buttonDy_Click(object sender, EventArgs e) if (textBox1.Text = "") textBox1.Text = "" else switch (fh) case "+": t
13、extBox1.Text = Convert.ToString(Convert.ToDouble(first) + Convert.ToDouble(textBox1.Text); break; case "-": textBox1.Text = Convert.ToString(Convert.ToDouble(first) - Convert.ToDouble(textBox1.Text); break; case "*": textBox1.Text = Convert.ToString(Convert.ToDouble(first) * Convert.ToDouble(textBox1.Text); break; case "/": if (Convert.ToDouble(textBox1.Text) = 0) MessageBox.Show("除數(shù)不能為0", "錯誤", MessageBoxButtons.OK, MessageBoxIcon.Error); else textBox1.Text = Convert.ToString(Convert.ToDo
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 南大版一年級心理健康第14課《我愛你們》課件
- 7.2《走向未來》-課件- -2024-2025學(xué)年統(tǒng)編版道德與法治九年級下冊
- 2025屆太白縣四下數(shù)學(xué)期末達(dá)標(biāo)檢測試題含解析
- 青島市李滄區(qū)2025年六年級下學(xué)期5月模擬預(yù)測數(shù)學(xué)試題含解析
- 武漢科技大學(xué)《能源法》2023-2024學(xué)年第二學(xué)期期末試卷
- 廣東工業(yè)大學(xué)《西方音樂史與名作欣賞Ⅱ》2023-2024學(xué)年第二學(xué)期期末試卷
- 云南機(jī)電職業(yè)技術(shù)學(xué)院《花鳥》2023-2024學(xué)年第二學(xué)期期末試卷
- 淘寶運(yùn)營提成合同范本
- 高效解析藥物在人體內(nèi)作用的光譜技術(shù)研究與應(yīng)用趨勢
- 石家莊理工職業(yè)學(xué)院《化工原理2》2023-2024學(xué)年第二學(xué)期期末試卷
- 生物節(jié)律調(diào)節(jié)課件
- 2025年黑龍江民族職業(yè)學(xué)院單招職業(yè)技能測試題庫匯編
- 感恩父母課件:父母的愛如山如水
- 2020-2025年中國國有控股公司行業(yè)發(fā)展趨勢及投資前景預(yù)測報告
- 病區(qū)8S管理成果匯報
- 民法典題庫(附答案)
- 綏芬河市2025年上半年招考事業(yè)單位專業(yè)人員易考易錯模擬試題(共500題)試卷后附參考答案
- 小學(xué)數(shù)學(xué)新課程標(biāo)準(zhǔn)(教育部2024年制訂)
- 2025復(fù)工復(fù)產(chǎn)安全教育培訓(xùn)
- 2024年叉車司機(jī)車輛基本操作知識考試題庫及答案(共70題)
- 工業(yè)統(tǒng)計知識培訓(xùn)
評論
0/150
提交評論