当前位置:首页 > 代码 > 正文

微信计算器源代码(微信计算器源代码怎么用)[20240427更新]

admin 发布:2024-04-27 11:43 124


本篇文章给大家谈谈微信计算器源代码,以及微信计算器源代码怎么用对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。

本文目录一览:

java计算器的源代码

import java.awt.*;

import java.awt.event.*;

import java.lang.*;

import javax.swing.*;

public class Counter extends Frame

{

//声明三个面板的布局

GridLayout gl1,gl2,gl3;

Panel p0,p1,p2,p3;

JTextField tf1;

TextField tf2;

Button b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15,b16,b17,b18,b19,b20,b21,b22,b23,b24,b25,b26;

StringBuffer str;//显示屏所显示的字符串

double x,y;//x和y都是运算数

int z;//Z表示单击了那一个运算符.0表示"+",1表示"-",2表示"*",3表示"/"

static double m;//记忆的数字

public Counter()

{

gl1=new GridLayout(1,4,10,0);//实例化三个面板的布局

gl2=new GridLayout(4,1,0,15);

gl3=new GridLayout(4,5,10,15);

tf1=new JTextField(27);//显示屏

tf1.setHorizontalAlignment(JTextField.RIGHT);

tf1.setEnabled(false);

tf1.setText("0");

tf2=new TextField(10);//显示记忆的索引值

tf2.setEditable(false);

//实例化所有按钮、设置其前景色并注册监听器

b0=new Button("Backspace");

b0.setForeground(Color.red);

b0.addActionListener(new Bt());

b1=new Button("CE");

b1.setForeground(Color.red);

b1.addActionListener(new Bt());

b2=new Button("C");

b2.setForeground(Color.red);

b2.addActionListener(new Bt());

b3=new Button("MC");

b3.setForeground(Color.red);

b3.addActionListener(new Bt());

b4=new Button("MR");

b4.setForeground(Color.red);

b4.addActionListener(new Bt());

b5=new Button("MS");

b5.setForeground(Color.red);

b5.addActionListener(new Bt());

b6=new Button("M+");

b6.setForeground(Color.red);

b6.addActionListener(new Bt());

b7=new Button("7");

b7.setForeground(Color.blue);

b7.addActionListener(new Bt());

b8=new Button("8");

b8.setForeground(Color.blue);

b8.addActionListener(new Bt());

b9=new Button("9");

b9.setForeground(Color.blue);

b9.addActionListener(new Bt());

b10=new Button("/");

b10.setForeground(Color.red);

b10.addActionListener(new Bt());

b11=new Button("sqrt");

b11.setForeground(Color.blue);

b11.addActionListener(new Bt());

b12=new Button("4");

b12.setForeground(Color.blue);

b12.addActionListener(new Bt());

b13=new Button("5");

b13.setForeground(Color.blue);

b13.addActionListener(new Bt());

b14=new Button("6");

b14.setForeground(Color.blue);

b14.addActionListener(new Bt());

b15=new Button("*");

b15.setForeground(Color.red);

b15.addActionListener(new Bt());

b16=new Button("%");

b16.setForeground(Color.blue);

b16.addActionListener(new Bt());

b17=new Button("1");

b17.setForeground(Color.blue);

b17.addActionListener(new Bt());

b18=new Button("2");

b18.setForeground(Color.blue);

b18.addActionListener(new Bt());

b19=new Button("3");

b19.setForeground(Color.blue);

b19.addActionListener(new Bt());

b20=new Button("-");

b20.setForeground(Color.red);

b20.addActionListener(new Bt());

b21=new Button("1/X");

b21.setForeground(Color.blue);

b21.addActionListener(new Bt());

b22=new Button("0");

b22.setForeground(Color.blue);

b22.addActionListener(new Bt());

b23=new Button("+/-");

b23.setForeground(Color.blue);

b23.addActionListener(new Bt());

b24=new Button(".");

b24.setForeground(Color.blue);

b24.addActionListener(new Bt());

b25=new Button("+");

b25.setForeground(Color.red);

b25.addActionListener(new Bt());

b26=new Button("=");

b26.setForeground(Color.red);

b26.addActionListener(new Bt());

//实例化四个面板

p0=new Panel();

p1=new Panel();

p2=new Panel();

p3=new Panel();

//创建一个空字符串缓冲区

str=new StringBuffer();

//添加面板p0中的组件和设置其在框架中的位置和大小

p0.add(tf1);

p0.setBounds(10,25,300,40);

//添加面板p1中的组件和设置其在框架中的位置和大小

p1.setLayout(gl1);

p1.add(tf2);

p1.add(b0);

p1.add(b1);

p1.add(b2);

p1.setBounds(10,65,300,25);

//添加面板p2中的组件并设置其的框架中的位置和大小

p2.setLayout(gl2);

p2.add(b3);

p2.add(b4);

p2.add(b5);

p2.add(b6);

p2.setBounds(10,110,40,150);

//添加面板p3中的组件并设置其在框架中的位置和大小

p3.setLayout(gl3);//设置p3的布局

p3.add(b7);

p3.add(b8);

p3.add(b9);

p3.add(b10);

p3.add(b11);

p3.add(b12);

p3.add(b13);

p3.add(b14);

p3.add(b15);

p3.add(b16);

p3.add(b17);

p3.add(b18);

p3.add(b19);

p3.add(b20);

p3.add(b21);

p3.add(b22);

p3.add(b23);

p3.add(b24);

p3.add(b25);

p3.add(b26);

p3.setBounds(60,110,250,150);

//设置框架中的布局为空布局并添加4个面板

setLayout(null);

add(p0);

add(p1);

add(p2);

add(p3);

setResizable(false);//禁止调整框架的大小

//匿名类关闭窗口

addWindowListener(new WindowAdapter(){

public void windowClosing(WindowEvent e1)

{

System.exit(0);

}

});

setBackground(Color.lightGray);

setBounds(100,100,320,280);

setVisible(true);

}

//构造监听器

class Bt implements ActionListener

{

public void actionPerformed(ActionEvent e2)

{

try{

if(e2.getSource()==b1)//选择"CE"清零

{

tf1.setText("0");//把显示屏清零

str.setLength(0);//清空字符串缓冲区以准备接收新的输入运算数

}

else if(e2.getSource()==b2)//选择"C"清零

{

tf1.setText("0");//把显示屏清零

str.setLength(0);

}

else if(e2.getSource()==b23)//单击"+/-"选择输入的运算数是正数还是负数

{

x=Double.parseDouble(tf1.getText().trim());

tf1.setText(""+(-x));

}

else if(e2.getSource()==b25)//单击加号按钮获得x的值和z的值并清空y的值

{

x=Double.parseDouble(tf1.getText().trim());

str.setLength(0);//清空缓冲区以便接收新的另一个运算数

y=0d;

z=0;

}

else if(e2.getSource()==b20)//单击减号按钮获得x的值和z的值并清空y的值

{

x=Double.parseDouble(tf1.getText().trim());

str.setLength(0);

y=0d;

z=1;

}

else if(e2.getSource()==b15)//单击乘号按钮获得x的值和z的值并清空y的值

{

x=Double.parseDouble(tf1.getText().trim());

str.setLength(0);

y=0d;

z=2;

}

else if(e2.getSource()==b10)//单击除号按钮获得x的值和z的值并空y的值

{

x=Double.parseDouble(tf1.getText().trim());

str.setLength(0);

y=0d;

z=3;

}

else if(e2.getSource()==b26)//单击等号按钮输出计算结果

{

str.setLength(0);

switch(z)

{

case 0 : tf1.setText(""+(x+y));break;

case 1 : tf1.setText(""+(x-y));break;

case 2 : tf1.setText(""+(x*y));break;

case 3 : tf1.setText(""+(x/y));break;

}

}

else if(e2.getSource()==b24)//单击"."按钮输入小数

{

if(tf1.getText().trim().indexOf(′.′)!=-1)//判断字符串中是否已经包含了小数点

{

}

else//如果没数点有小

{

if(tf1.getText().trim().equals("0"))//如果初时显示为0

{

str.setLength(0);

tf1.setText((str.append("0"+e2.getActionCommand())).toString());

}

else if(tf1.getText().trim().equals(""))//如果初时显示为空则不做任何操作

{

}

else

{

tf1.setText(str.append(e2.getActionCommand()).toString());

}

}

y=0d;

}

else if(e2.getSource()==b11)//求平方根

{

x=Double.parseDouble(tf1.getText().trim());

tf1.setText("数字格式异常");

if(x0)

tf1.setText("负数没有平方根");

else

tf1.setText(""+Math.sqrt(x));

str.setLength(0);

y=0d;

}

else if(e2.getSource()==b16)//单击了"%"按钮

{

x=Double.parseDouble(tf1.getText().trim());

tf1.setText(""+(0.01*x));

str.setLength(0);

y=0d;

}

else if(e2.getSource()==b21)//单击了"1/X"按钮

{

x=Double.parseDouble(tf1.getText().trim());

if(x==0)

{

tf1.setText("除数不能为零");

}

else

{

tf1.setText(""+(1/x));

}

str.setLength(0);

y=0d;

}

else if(e2.getSource()==b3)//MC为清除内存

{

m=0d;

tf2.setText("");

str.setLength(0);

}

else if(e2.getSource()==b4)//MR为重新调用存储的数据

{

if(tf2.getText().trim()!="")//有记忆数字

{

tf1.setText(""+m);

}

}

else if(e2.getSource()==b5)//MS为存储显示的数据

{

m=Double.parseDouble(tf1.getText().trim());

tf2.setText("M");

tf1.setText("0");

str.setLength(0);

}

else if(e2.getSource()==b6)//M+为将显示的数字与已经存储的数据相加要查看新的数字单击MR

{

m=m+Double.parseDouble(tf1.getText().trim());

}

else//选择的是其他的按钮

{

if(e2.getSource()==b22)//如果选择的是"0"这个数字键

{

if(tf1.getText().trim().equals("0"))//如果显示屏显示的为零不做操作

{

}

else

{

tf1.setText(str.append(e2.getActionCommand()).toString());

y=Double.parseDouble(tf1.getText().trim());

}

}

else if(e2.getSource()==b0)//选择的是“BackSpace”按钮

{

if(!tf1.getText().trim().equals("0"))//如果显示屏显示的不是零

{

if(str.length()!=1)

{

tf1.setText(str.delete(str.length()-1,str.length()).toString());//可能抛出字符串越界异常

}

else

{

tf1.setText("0");

str.setLength(0);

}

}

y=Double.parseDouble(tf1.getText().trim());

}

else//其他的数字键

{

tf1.setText(str.append(e2.getActionCommand()).toString());

y=Double.parseDouble(tf1.getText().trim());

}

}

}

catch(NumberFormatException e){

tf1.setText("数字格式异常");

}

catch(StringIndexOutOfBoundsException e){

tf1.setText("字符串索引越界");

}

}

}

public static void main(String args[])

{

new Counter();

}

}

你在JAVA的环境中运行一下。

这题目也是我的作业,我运行的了。

计算器源代码

using System;

using System.Drawing;

using System.Collections;

using System.ComponentModel;

using System.Windows.Forms;

using System.Data;

using System.Runtime.InteropServices;

using System.IO;

namespace 计算器

{

/// summary

/// Form1 的摘要说明。

/// /summary

public class Form1 : System.Windows.Forms.Form

{

private System.Windows.Forms.TextBox textBox1;

private System.Windows.Forms.Label label1;

private System.Windows.Forms.Button button1;

private System.Windows.Forms.Button button2;

private System.Windows.Forms.Button button3;

private System.Windows.Forms.Button button4;

private System.Windows.Forms.Button button5;

private System.Windows.Forms.Button button6;

private System.Windows.Forms.Button button7;

private System.Windows.Forms.Button button8;

private System.Windows.Forms.Button button9;

private System.Windows.Forms.Button button11;

private System.Windows.Forms.Button button12;

private System.Windows.Forms.Button button13;

private System.Windows.Forms.Button button14;

private System.Windows.Forms.Button button15;

private System.Windows.Forms.Button button16;

private System.Windows.Forms.Button button17;

private System.Windows.Forms.Button button10;

private System.Windows.Forms.Button button18;

private System.Windows.Forms.Button button19;

private AxWMPLib.AxWindowsMediaPlayer axWindowsMediaPlayer1;

private System.Windows.Forms.PictureBox pictureBox1;

private System.ComponentModel.Container components = null;

public Form1()

{

//

// Windows 窗体设计器支持所必需的

//

InitializeComponent();

//

// TODO: 在 InitializeComponent 调用后添加任何构造函数代码

//

}

/// summary

/// 清理所有正在使用的资源。

/// /summary

protected override void Dispose( bool disposing )

{

if( disposing )

{

if (components != null)

{

components.Dispose();

}

}

base.Dispose( disposing );

}

#region Windows 窗体设计器生成的代码

/// summary

/// 设计器支持所需的方法 - 不要使用代码编辑器修改

/// 此方法的内容。

/// /summary

private void InitializeComponent()

{

System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));

this.textBox1 = new System.Windows.Forms.TextBox();

this.label1 = new System.Windows.Forms.Label();

this.button1 = new System.Windows.Forms.Button();

this.button2 = new System.Windows.Forms.Button();

this.button3 = new System.Windows.Forms.Button();

this.button4 = new System.Windows.Forms.Button();

this.button5 = new System.Windows.Forms.Button();

this.button6 = new System.Windows.Forms.Button();

this.button7 = new System.Windows.Forms.Button();

this.button8 = new System.Windows.Forms.Button();

this.button9 = new System.Windows.Forms.Button();

this.button11 = new System.Windows.Forms.Button();

this.button12 = new System.Windows.Forms.Button();

this.button13 = new System.Windows.Forms.Button();

this.button14 = new System.Windows.Forms.Button();

this.button15 = new System.Windows.Forms.Button();

this.button16 = new System.Windows.Forms.Button();

this.button17 = new System.Windows.Forms.Button();

this.button10 = new System.Windows.Forms.Button();

this.button18 = new System.Windows.Forms.Button();

this.button19 = new System.Windows.Forms.Button();

this.axWindowsMediaPlayer1 = new AxWMPLib.AxWindowsMediaPlayer();

this.pictureBox1 = new System.Windows.Forms.PictureBox();

((System.ComponentModel.ISupportInitialize)(this.axWindowsMediaPlayer1)).BeginInit();

this.SuspendLayout();

//

// textBox1

//

this.textBox1.Location = new System.Drawing.Point(112, 32);

this.textBox1.Name = "textBox1";

this.textBox1.Size = new System.Drawing.Size(240, 29);

this.textBox1.TabIndex = 0;

this.textBox1.Text = "";

//

// label1

//

this.label1.Font = new System.Drawing.Font("楷体_GB2312", 15F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));

this.label1.Location = new System.Drawing.Point(24, 40);

this.label1.Name = "label1";

this.label1.Size = new System.Drawing.Size(72, 40);

this.label1.TabIndex = 1;

this.label1.Text = "结果";

//

// button1

//

this.button1.Location = new System.Drawing.Point(24, 168);

this.button1.Name = "button1";

this.button1.Size = new System.Drawing.Size(40, 32);

this.button1.TabIndex = 3;

this.button1.Text = "1";

this.button1.Click += new System.EventHandler(this.button1_Click);

//

// button2

//

this.button2.Location = new System.Drawing.Point(88, 168);

this.button2.Name = "button2";

this.button2.Size = new System.Drawing.Size(40, 32);

this.button2.TabIndex = 4;

this.button2.Text = "2";

this.button2.Click += new System.EventHandler(this.button2_Click);

//

// button3

//

this.button3.Location = new System.Drawing.Point(152, 168);

this.button3.Name = "button3";

this.button3.Size = new System.Drawing.Size(40, 32);

this.button3.TabIndex = 5;

this.button3.Text = "3";

this.button3.Click += new System.EventHandler(this.button3_Click);

//

// button4

//

this.button4.Location = new System.Drawing.Point(24, 216);

this.button4.Name = "button4";

this.button4.Size = new System.Drawing.Size(40, 32);

this.button4.TabIndex = 6;

this.button4.Text = "4";

this.button4.Click += new System.EventHandler(this.button4_Click);

//

// button5

//

this.button5.Location = new System.Drawing.Point(88, 216);

this.button5.Name = "button5";

this.button5.Size = new System.Drawing.Size(40, 32);

this.button5.TabIndex = 7;

this.button5.Text = "5";

this.button5.Click += new System.EventHandler(this.button5_Click);

//

// button6

//

this.button6.Location = new System.Drawing.Point(152, 216);

this.button6.Name = "button6";

this.button6.Size = new System.Drawing.Size(40, 32);

this.button6.TabIndex = 8;

this.button6.Text = "6";

this.button6.Click += new System.EventHandler(this.button6_Click);

//

// button7

//

this.button7.Location = new System.Drawing.Point(24, 264);

this.button7.Name = "button7";

this.button7.Size = new System.Drawing.Size(40, 32);

this.button7.TabIndex = 9;

this.button7.Text = "7";

this.button7.Click += new System.EventHandler(this.button7_Click);

//

// button8

//

this.button8.Location = new System.Drawing.Point(88, 264);

this.button8.Name = "button8";

this.button8.Size = new System.Drawing.Size(40, 32);

this.button8.TabIndex = 10;

this.button8.Text = "8";

this.button8.Click += new System.EventHandler(this.button8_Click);

//

// button9

//

this.button9.Location = new System.Drawing.Point(152, 264);

this.button9.Name = "button9";

this.button9.Size = new System.Drawing.Size(40, 32);

this.button9.TabIndex = 11;

this.button9.Text = "9";

this.button9.Click += new System.EventHandler(this.button9_Click);

//

// button11

//

this.button11.Location = new System.Drawing.Point(152, 320);

this.button11.Name = "button11";

this.button11.Size = new System.Drawing.Size(40, 32);

this.button11.TabIndex = 13;

this.button11.Text = "=";

this.button11.Click += new System.EventHandler(this.button11_Click);

//

// button12

//

this.button12.Location = new System.Drawing.Point(152, 120);

this.button12.Name = "button12";

this.button12.Size = new System.Drawing.Size(40, 32);

this.button12.TabIndex = 14;

this.button12.Text = "/";

this.button12.Click += new System.EventHandler(this.button12_Click);

//

// button13

//

this.button13.Location = new System.Drawing.Point(208, 120);

this.button13.Name = "button13";

this.button13.Size = new System.Drawing.Size(40, 32);

this.button13.TabIndex = 15;

this.button13.Text = "*";

this.button13.Click += new System.EventHandler(this.button13_Click);

//

// button14

//

this.button14.Location = new System.Drawing.Point(208, 168);

this.button14.Name = "button14";

this.button14.Size = new System.Drawing.Size(40, 32);

this.button14.TabIndex = 16;

this.button14.Text = "-";

this.button14.Click += new System.EventHandler(this.button14_Click);

//

// button15

//

this.button15.Location = new System.Drawing.Point(208, 216);

this.button15.Name = "button15";

this.button15.Size = new System.Drawing.Size(40, 32);

this.button15.TabIndex = 17;

this.button15.Text = "+";

this.button15.Click += new System.EventHandler(this.button15_Click);

//

// button16

//

this.button16.Location = new System.Drawing.Point(24, 120);

this.button16.Name = "button16";

this.button16.Size = new System.Drawing.Size(104, 32);

this.button16.TabIndex = 18;

this.button16.Text = "播放音乐";

this.button16.Click += new System.EventHandler(this.button16_Click);

//

// button17

//

this.button17.Location = new System.Drawing.Point(208, 264);

this.button17.Name = "button17";

this.button17.Size = new System.Drawing.Size(40, 88);

this.button17.TabIndex = 19;

this.button17.Text = "C";

this.button17.Click += new System.EventHandler(this.button17_Click);

//

// button10

//

this.button10.Location = new System.Drawing.Point(24, 320);

this.button10.Name = "button10";

this.button10.Size = new System.Drawing.Size(56, 32);

this.button10.TabIndex = 20;

this.button10.Text = "0";

this.button10.Click += new System.EventHandler(this.button10_Click);

//

// button18

//

this.button18.Location = new System.Drawing.Point(304, 312);

this.button18.Name = "button18";

this.button18.Size = new System.Drawing.Size(80, 40);

this.button18.TabIndex = 21;

this.button18.Text = "关闭";

this.button18.Click += new System.EventHandler(this.button18_Click);

//

// button19

//

this.button19.Location = new System.Drawing.Point(88, 320);

this.button19.Name = "button19";

this.button19.Size = new System.Drawing.Size(40, 32);

this.button19.TabIndex = 24;

this.button19.Text = ".";

this.button19.Click += new System.EventHandler(this.button19_Click);

//

// axWindowsMediaPlayer1

//

this.axWindowsMediaPlayer1.Enabled = true;

this.axWindowsMediaPlayer1.Location = new System.Drawing.Point(272, 80);

this.axWindowsMediaPlayer1.Name = "axWindowsMediaPlayer1";

this.axWindowsMediaPlayer1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axWindowsMediaPlayer1.OcxState")));

this.axWindowsMediaPlayer1.Size = new System.Drawing.Size(112, 168);

this.axWindowsMediaPlayer1.TabIndex = 25;

this.axWindowsMediaPlayer1.Enter += new System.EventHandler(this.axWindowsMediaPlayer1_Enter);

//

// pictureBox1

//

this.pictureBox1.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("pictureBox1.BackgroundImage")));

this.pictureBox1.Location = new System.Drawing.Point(272, 184);

this.pictureBox1.Name = "pictureBox1";

this.pictureBox1.Size = new System.Drawing.Size(112, 104);

this.pictureBox1.TabIndex = 28;

this.pictureBox1.TabStop = false;

//

// Form1

//

this.AutoScaleBaseSize = new System.Drawing.Size(10, 22);

this.BackColor = System.Drawing.SystemColors.Control;

this.ClientSize = new System.Drawing.Size(408, 398);

this.Controls.Add(this.pictureBox1);

this.Controls.Add(this.axWindowsMediaPlayer1);

this.Controls.Add(this.button19);

this.Controls.Add(this.button18);

this.Controls.Add(this.button10);

this.Controls.Add(this.button17);

this.Controls.Add(this.button16);

this.Controls.Add(this.button15);

this.Controls.Add(this.button14);

this.Controls.Add(this.button13);

this.Controls.Add(this.button12);

this.Controls.Add(this.button11);

this.Controls.Add(this.button9);

this.Controls.Add(this.button8);

this.Controls.Add(this.button7);

this.Controls.Add(this.button6);

this.Controls.Add(this.button5);

this.Controls.Add(this.button4);

this.Controls.Add(this.button3);

this.Controls.Add(this.button2);

this.Controls.Add(this.button1);

this.Controls.Add(this.label1);

this.Controls.Add(this.textBox1);

this.Font = new System.Drawing.Font("楷体_GB2312", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));

this.Name = "Form1";

this.Text = "计算器";

((System.ComponentModel.ISupportInitialize)(this.axWindowsMediaPlayer1)).EndInit();

this.ResumeLayout(false);

}

#endregion

/// summary

/// 应用程序的主入口点。

/// /summary

[STAThread]

static void Main()

{

Application.Run(new Form1());

}

private void button1_Click(object sender, System.EventArgs e)

{

Button btn=(Button)sender;

textBox1.Text+=btn.Text;

}

private void button2_Click(object sender, System.EventArgs e)

{

Button btn=(Button)sender;

textBox1.Text+=btn.Text;

}

private void button3_Click(object sender, System.EventArgs e)

{

Button btn=(Button)sender;

textBox1.Text+=btn.Text;

}

private void button4_Click(object sender, System.EventArgs e)

{

Button btn=(Button)sender;

textBox1.Text+=btn.Text;

}

private void button5_Click(object sender, System.EventArgs e)

{

Button btn=(Button)sender;

textBox1.Text+=btn.Text;

}

private void button6_Click(object sender, System.EventArgs e)

{

Button btn=(Button)sender;

textBox1.Text+=btn.Text;

}

private void button7_Click(object sender, System.EventArgs e)

{

Button btn=(Button)sender;

textBox1.Text+=btn.Text;

}

private void button8_Click(object sender, System.EventArgs e)

{

Button btn=(Button)sender;

textBox1.Text+=btn.Text;

}

private void button9_Click(object sender, System.EventArgs e)

{

Button btn=(Button)sender;

textBox1.Text+=btn.Text;

}

private void button10_Click(object sender, System.EventArgs e)

{

Button btn=(Button)sender;

textBox1.Text+=btn.Text;

}

private void button19_Click(object sender, System.EventArgs e)

{

Button btn=(Button)sender;

textBox1.Text+=btn.Text;

}

private void button12_Click(object sender, System.EventArgs e)

{

Button btn=(Button)sender;

textBox1.Text=textBox1.Text+" "+btn.Text+" ";

}

private void button13_Click(object sender, System.EventArgs e)

{

Button btn=(Button)sender;

textBox1.Text=textBox1.Text+" "+btn.Text+" ";

}

private void button14_Click(object sender, System.EventArgs e)

{

Button btn=(Button)sender;

textBox1.Text=textBox1.Text+" "+btn.Text+" ";

}

private void button15_Click(object sender, System.EventArgs e)

{

Button btn=(Button)sender;

textBox1.Text=textBox1.Text+" "+btn.Text+" ";

}

private void button16_Click(object sender, System.EventArgs e)

{

FileDialog ofDialog=new OpenFileDialog();

ofDialog.AddExtension=true;

ofDialog.CheckFileExists=true;

ofDialog.CheckPathExists=true;

ofDialog.Filter="VCD文件(*.dat)|*.dat|Audio文件(*.avi)|*.avi|WAV文件(*.wav)|*.wav|MP3文件(*.mp3)|*.mp3|所有文件(*.*)|*.*";

ofDialog.FilterIndex=4;

if(ofDialog.ShowDialog()==DialogResult.OK)

{

this.axWindowsMediaPlayer1.URL=ofDialog.FileName;

}

}

private void button17_Click(object sender, System.EventArgs e)

{

textBox1.Text="";

}

private void button18_Click(object sender, System.EventArgs e)

{

Application.Exit();

}

private void button11_Click(object sender,System.EventArgs e)

{

Single r=0;

string t=textBox1.Text;

int space = t.IndexOf(' ');

string S1=t.Substring(0,space);

char op=Convert.ToChar(t.Substring(space+1,1));

string S2=t.Substring(space+3);

Single arg1=Convert.ToSingle(S1);

Single arg2=Convert.ToSingle(S2);

switch(op)

{

case '+':

r=arg1+arg2;

break;

case '-':

r=arg1-arg2;

break;

case '*':

r=arg1*arg2;

break;

case '/':

if(arg2==0)

textBox1.Text="error!";

else

r=arg1/arg2;

break;

}

textBox1.Text=r.ToString();

}

private void axWindowsMediaPlayer1_Enter(object sender, System.EventArgs e)

{

}

}

}

微信怎么用计算机自动计算?

随着微信版本的更新,出现了很多的小功能,其中计算器就是一个,很多伙伴还不会用, 下面我就详细给大家讲一下。

打开微信开发工具,新建一个项目,命名为calculate。

新建page,输入名称为calculate。

calculate目录下自动生成4个文件。

打开calculate.json文件,使其pages/calculate/calculate文件处在第一项。

5.编写calculate.wxml,输入:

6.编写calculate.wcss,输入:.container{justify-content: flexstart;padding:30rpx0;}

container input{background-color: #eee;border-radius: 3px;text-align: left;width: 720rpx;height: 100rpx;line-height: 100rpx;margin:20rpx;}container button{width: 100%;

7.编写calculate.js,输入代码:data:{num1:"",num2:"",result:""},getNum1:function(e){var n=e.detail.value;if(!isNaN(n{this.setData({num1:n});}},getNum2:function(e{var n=e.detail.value;if(!isNaN(n)){this.setData({num2:n});}},add:function(e){varn=this.data.num1*1+this.data.num2*1;this.setData({result:n});},

8.输入完成后,保存代码,得到如下计算器的界面如下。

9.在输入框中,输入数字,并点击确定按钮,则得到运算结果。

微信上的小程序 怎么做一个计算器

小程序就是一套类似的css+js+html的包装,会前段的设计就问题不大,html+css做计算器的界面,js写逻辑,具体请参考小程序开发教程

微信吸粉神器 生命计算器/生逢何时 微信小游戏源码

拿到源码不会程序的人也没法用,会程序的人不需要源码也能做。

关于微信计算器源代码和微信计算器源代码怎么用的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。

版权说明:如非注明,本站文章均为 AH站长 原创,转载请注明出处和附带本文链接;

本文地址:http://www.ahzz.com.cn/post/690.html


取消回复欢迎 发表评论:

分享到

温馨提示

下载成功了么?或者链接失效了?

联系我们反馈

立即下载