




下載本文檔
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
1、實(shí)驗(yàn)五/六:Windows界面設(shè)計基礎(chǔ)一、實(shí)驗(yàn)?zāi)康氖煜indows窗體及其各種基本控件的功能和用法二、實(shí)驗(yàn)內(nèi)容利用Windows窗體及其各種基本控件實(shí)現(xiàn)簡易計算器。三、實(shí)驗(yàn)組織運(yùn)行要求編寫的源程序要立即上機(jī)編譯運(yùn)行來檢驗(yàn)程序中存在的問題。通過運(yùn)行的結(jié)果驗(yàn)證程序的功能是否實(shí)現(xiàn)。有一些系統(tǒng)類的方法、變量也需要上機(jī)實(shí)驗(yàn)去了解它們的含義。四、實(shí)驗(yàn)條件Windows XP, Visual Studio 2005五、實(shí)驗(yàn)步驟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)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2024-2025年秋季語文閱讀推廣計劃
- 2025年國際軟件技術(shù)支持服務(wù)合同
- 2025年企業(yè)標(biāo)識設(shè)計創(chuàng)意策劃服務(wù)合同
- 2025年企業(yè)剝離資產(chǎn)合同策劃與管理規(guī)定
- 2025年建設(shè)場地準(zhǔn)備合同模板
- 2025年動感單車健身房會員指導(dǎo)合同
- 2025年跨境電商空運(yùn)服務(wù)合同
- 2025年全球貿(mào)易合同范本與文件規(guī)范
- 2025年個人房產(chǎn)抵押貸款責(zé)任合同
- 車輛維修合同協(xié)議書(28篇)
- 數(shù)據(jù)通信基礎(chǔ) 數(shù)據(jù)通信與計算機(jī)網(wǎng)絡(luò)教學(xué)課件
- ZYX30隔絕式壓縮氧氣自救器說明書
- 碳化硅與氮化鎵功率器件
- 小學(xué)二年級下冊道德與法治全冊教案
- 石油化工設(shè)備維護(hù)檢修規(guī)程-通用設(shè)備1
- 變壓器拆除申請
- 23S519 小型排水構(gòu)筑物(帶書簽)
- 重大危險源辨識清單
- 工業(yè)地產(chǎn)培訓(xùn)課件
- 皮膚病學(xué)-動物性皮膚病課件
- 涉詐風(fēng)險賬戶審查表
評論
0/150
提交評論