Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,028

HOME > .NET Framework > Forum > โปรแกรมเครื่องคิดเลขอยากทราบ Function เพิ่มเติมหน่อยครับ



 

โปรแกรมเครื่องคิดเลขอยากทราบ Function เพิ่มเติมหน่อยครับ

 



Topic : 093704



โพสกระทู้ ( 109 )
บทความ ( 0 )



สถานะออฟไลน์




ผมอยากทราบว่าโปรแกรมเครื่องคิดเลขถ้าเราต้องการให้ + - * / แบบ ต่อเนื่องเลยโดยไม่ต้องกด = ก่อนนี่ ต้องเพิ่มฟั่งชั่นหรือเงื่อนไขอะไรเพิ่มเติมตรงไหนครับ รบกวนหน่อยครับ

Code (C#)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsCaculator
{
    public partial class Form1 : Form
    {

        //int a;
        bool plus = false;
        bool minus = false;
        bool multiply = false;
        bool divide = false;
        bool power = false;


        public Form1()
        {
            InitializeComponent();
        }


        private void num_0_Click(object sender, EventArgs e)
        {
          textBox1.Text = textBox1.Text + "0";

        }

        private void num_1_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + "1";
           
        }

        private void num_2_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + "2";
           
        }

        private void num_3_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + "3";
           
        }

        private void num_4_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + "4";

        }

        private void num_5_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + "5";

        }

        private void num_6_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + "6";
        }

        private void num_7_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + "7";
           
        }

        private void num_8_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + "8";
          
        }

        private void num_9_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + "9";
        }

        private void btnBackspace_Click(object sender, EventArgs e)
        {
            int a = textBox1.Text.Length;
            if (textBox1.Text == "")
            {
                textBox1.Text = "";
            }
            else
            {
                textBox1.Text = textBox1.Text.Remove(a - 1);
            }


        }

        private void btnClear_Click(object sender, EventArgs e)
        {
            //if (textBox1.Text == "")
            //    return;
            //textBox1.Text = "";
            textBox1.Clear();
        }

        private void button1_Click(object sender, EventArgs e)
        {
             if  (plus)
            {
                decimal dec = Convert.ToDecimal(textBox1.Tag) + Convert.ToDecimal(textBox1.Text);
                textBox1.Text = dec.ToString();
            }
            else if (minus) 
            {
                decimal dec = Convert.ToDecimal(textBox1.Tag) - Convert.ToDecimal(textBox1.Text);
                textBox1.Text = dec.ToString();
            }
            else if (multiply)
            {
                decimal dec = Convert.ToDecimal(textBox1.Tag) * Convert.ToDecimal(textBox1.Text);
                textBox1.Text = dec.ToString();
            }
            else if (divide)
            {
                if (textBox1.Text == "0")
                {
                    textBox1.Text = "0";
                }
                else if (textBox1.Text != "0")
                {
                    decimal dec = Convert.ToDecimal(textBox1.Tag) / Convert.ToDecimal(textBox1.Text);
                    textBox1.Text = dec.ToString();
                }
            }
            else if (power)
            {
                decimal dec = Convert.ToDecimal(textBox1.Tag) * Convert.ToDecimal(textBox1.Tag);
                textBox1.Text = dec.ToString();
            }

            return ;

        }

        private void btnKoon_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "")
            {
                return;
            }
            else
            {
                multiply = true;
                textBox1.Tag = textBox1.Text;
                textBox1.Text = "";
            }

        }

        private void btnLopp_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "")
            {
                return;
            }
            else
            {
                minus = true;
                textBox1.Tag = textBox1.Text;
                textBox1.Text = "";
            }

        }

        private void btnBuak_Click(object sender, EventArgs e)
        {
           if (textBox1.Text == "")
            {
                return;
              
            }
            else
            {
                plus = true;
                textBox1.Tag = textBox1.Text;
                textBox1.Text = "";
                
            }
        }

        private void btnHan_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "")
            {
                return;
            }
            else
            {
                divide = true;
                textBox1.Tag = textBox1.Text;
                textBox1.Text = "";
            }

        }

        private void btnJud_Click(object sender, EventArgs e)
        {
            if (textBox1.Text.Contains("."))
            {
                return;
            }
            else
            {
                textBox1.Text = textBox1.Text + ".";
            }

        }




Tag : .NET, Ms SQL Server 2008, Web (ASP.NET), VS 2010 (.NET 4.x)







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2013-04-11 11:27:21 By : offonepoint View : 1350 Reply : 1
 

 

No. 1



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

สร้าง function สำหรับ กระทำค่าเป็น method ครับ จากนั้นก็เรียกจากทุก ๆ button ที่เป็น + - * / เอาครับ






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-04-11 17:34:14 By : mr.win
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : โปรแกรมเครื่องคิดเลขอยากทราบ Function เพิ่มเติมหน่อยครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 01
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่