mojoy 发表于 2004-12-28 10:11

如何用VB.NET编写计算器???

<P>各位大虾</P>
<P>      小弟最近在学习VB编程,近日需要编写一个计算器,但小弟资质尚浅,还请各位大虾能指点一二。</P>
<P>      希望哪位大哥有空帮我写个比较全面的计算器代码,并能把一些重要的代码解释一下,小弟谢过了!!!</P>[em01]

Mari 发表于 2004-12-28 19:49

数字计算器还是科学计算器?

mojoy 发表于 2004-12-30 09:35

我先学简单的,是数字计算器,科学的太深奥,一时半会搞不懂。还请指教!!!!

150640643 发表于 2005-11-7 21:58

<P>Public Class WebForm1<BR>    Inherits System.Web.UI.Page</P>
<P>#Region " Web 窗体设计器生成的代码 "</P>
<P>    '该调用是 Web 窗体设计器所必需的。<BR>    &lt;System.Diagnostics.DebuggerStepThrough()&gt; Private Sub InitializeComponent()</P>
<P>    End Sub<BR>    Protected WithEvents Button1 As System.Web.UI.WebControls.Button<BR>    Protected WithEvents Button2 As System.Web.UI.WebControls.Button<BR>    Protected WithEvents Button3 As System.Web.UI.WebControls.Button<BR>    Protected WithEvents Button4 As System.Web.UI.WebControls.Button<BR>    Protected WithEvents Button5 As System.Web.UI.WebControls.Button<BR>    Protected WithEvents Button6 As System.Web.UI.WebControls.Button<BR>    Protected WithEvents Button7 As System.Web.UI.WebControls.Button<BR>    Protected WithEvents Button8 As System.Web.UI.WebControls.Button<BR>    Protected WithEvents Button9 As System.Web.UI.WebControls.Button<BR>    Protected WithEvents Button10 As System.Web.UI.WebControls.Button<BR>    Protected WithEvents Button11 As System.Web.UI.WebControls.Button<BR>    Protected WithEvents Button12 As System.Web.UI.WebControls.Button<BR>    Protected WithEvents Button13 As System.Web.UI.WebControls.Button<BR>    Protected WithEvents Button14 As System.Web.UI.WebControls.Button<BR>    Protected WithEvents Button15 As System.Web.UI.WebControls.Button<BR>    Protected WithEvents Button16 As System.Web.UI.WebControls.Button<BR>    Protected WithEvents Button17 As System.Web.UI.WebControls.Button<BR>    Protected WithEvents Button18 As System.Web.UI.WebControls.Button<BR>    Protected WithEvents Button19 As System.Web.UI.WebControls.Button<BR>    Protected WithEvents Button20 As System.Web.UI.WebControls.Button<BR>    Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox<BR>    Protected WithEvents Label1 As System.Web.UI.WebControls.Label<BR>    Protected WithEvents Label2 As System.Web.UI.WebControls.Label<BR>    Protected WithEvents Label3 As System.Web.UI.WebControls.Label<BR>    Protected WithEvents Label4 As System.Web.UI.WebControls.Label<BR>    Protected WithEvents Label5 As System.Web.UI.WebControls.Label</P>
<P>    '注意: 以下占位符声明是 Web 窗体设计器所必需的。<BR>    '不要删除或移动它。<BR>    Private designerPlaceholderDeclaration As System.Object</P>
<P>    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init<BR>        'CODEGEN: 此方法调用是 Web 窗体设计器所必需的<BR>        '不要使用代码编辑器修改它。<BR>        InitializeComponent()<BR>    End Sub</P>
<P>#End Region</P>
<P>    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<BR>        '在此处放置初始化页的用户代码<BR>    End Sub</P>
<P>    Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button15.Click<BR>        If Label2.Text = "" Then           '除法的实现<BR>            Label3.Text = "/"<BR>            Label1.Text = TextBox1.Text<BR>            Label4.Text = TextBox1.Text<BR>        Else<BR>            Label2.Text = TextBox1.Text<BR>            Select Case Label3.Text<BR>                Case "+"<BR>                    TextBox1.Text = CDbl(Label1.Text) + CDbl(Label2.Text)<BR>                Case "*"<BR>                    TextBox1.Text = CDbl(Label1.Text) * CDbl(Label2.Text)<BR>                Case "-"<BR>                    TextBox1.Text = CDbl(Label1.Text) - CDbl(Label2.Text)<BR>                Case "/"<BR>                    TextBox1.Text = CDbl(Label1.Text) / CDbl(Label2.Text)<BR>                Case "1/x"<BR>                    TextBox1.Text = 1 / CDbl(Label1.Text)<BR>            End Select<BR>            Label3.Text = "/"<BR>            Label1.Text = TextBox1.Text<BR>            Label4.Text = TextBox1.Text</P>
<P>        End If<BR>    End Sub</P>
<P>    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click<BR>        If Label4.Text = "" Then<BR>            TextBox1.Text = TextBox1.Text &amp; "1"<BR>        Else<BR>            TextBox1.Text = ""<BR>            TextBox1.Text = TextBox1.Text &amp; "1"<BR>            Label4.Text = ""<BR>        End If</P>
<P>    End Sub</P>
<P>    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click<BR>        If Label4.Text = "" Then<BR>            TextBox1.Text = TextBox1.Text &amp; "2"<BR>        Else<BR>            TextBox1.Text = ""<BR>            TextBox1.Text = TextBox1.Text &amp; "2"<BR>            Label4.Text = ""<BR>        End If<BR>    End Sub</P>
<P>    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click<BR>        If Label4.Text = "" Then<BR>            TextBox1.Text = TextBox1.Text &amp; "3"<BR>        Else<BR>            TextBox1.Text = ""<BR>            TextBox1.Text = TextBox1.Text &amp; "3"<BR>            Label4.Text = ""<BR>        End If<BR>    End Sub</P>
<P>    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click<BR>        If Label4.Text = "" Then<BR>            TextBox1.Text = TextBox1.Text &amp; "4"<BR>        Else<BR>            TextBox1.Text = ""<BR>            TextBox1.Text = TextBox1.Text &amp; "4"<BR>            Label4.Text = ""<BR>        End If<BR>    End Sub</P>
<P>    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click<BR>        If Label4.Text = "" Then<BR>            TextBox1.Text = TextBox1.Text &amp; "5"<BR>        Else<BR>            TextBox1.Text = ""<BR>            TextBox1.Text = TextBox1.Text &amp; "5"<BR>            Label4.Text = ""<BR>        End If<BR>    End Sub</P>
<P>    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click<BR>        If Label4.Text = "" Then<BR>            TextBox1.Text = TextBox1.Text &amp; "6"<BR>        Else<BR>            TextBox1.Text = ""<BR>            TextBox1.Text = TextBox1.Text &amp; "6"<BR>            Label4.Text = ""<BR>        End If<BR>    End Sub</P>
<P>    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click<BR>        If Label4.Text = "" Then<BR>            TextBox1.Text = TextBox1.Text &amp; "7"<BR>        Else<BR>            TextBox1.Text = ""<BR>            TextBox1.Text = TextBox1.Text &amp; "7"<BR>            Label4.Text = ""<BR>        End If<BR>    End Sub</P>
<P>    Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click<BR>        If Label4.Text = "" Then<BR>            TextBox1.Text = TextBox1.Text &amp; "8"<BR>        Else<BR>            TextBox1.Text = ""<BR>            TextBox1.Text = TextBox1.Text &amp; "8"<BR>            Label4.Text = ""<BR>        End If<BR>    End Sub</P>
<P>    Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click<BR>        If Label4.Text = "" Then<BR>            TextBox1.Text = TextBox1.Text &amp; "9"<BR>        Else<BR>            TextBox1.Text = ""<BR>            TextBox1.Text = TextBox1.Text &amp; "9"<BR>            Label4.Text = ""<BR>        End If<BR>    End Sub</P>
<P>    Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click<BR>        If Label4.Text = "" Then<BR>            TextBox1.Text = TextBox1.Text &amp; "0"<BR>        Else<BR>            TextBox1.Text = ""<BR>            TextBox1.Text = TextBox1.Text &amp; "0"<BR>            Label4.Text = ""<BR>        End If<BR>    End Sub</P>
<P>    Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click<BR>        If Label4.Text = "" Then<BR>            TextBox1.Text = TextBox1.Text &amp; "."<BR>        Else<BR>            TextBox1.Text = ""<BR>            TextBox1.Text = TextBox1.Text &amp; "."<BR>            Label4.Text = ""<BR>        End If<BR>    End Sub</P>
<P>    Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click<BR>        If Label2.Text = "" Then                       '加法的实现<BR>            Label3.Text = "+"<BR>            Label1.Text = TextBox1.Text<BR>            Label4.Text = TextBox1.Text<BR>        Else<BR>            Label2.Text = TextBox1.Text<BR>            Select Case Label3.Text<BR>                Case "+"<BR>                    TextBox1.Text = CDbl(Label1.Text) + CDbl(Label2.Text)<BR>                Case "*"<BR>                    TextBox1.Text = CDbl(Label1.Text) * CDbl(Label2.Text)<BR>                Case "-"<BR>                    TextBox1.Text = CDbl(Label1.Text) - CDbl(Label2.Text)<BR>                Case "/"<BR>                    TextBox1.Text = CDbl(Label1.Text) / CDbl(Label2.Text)<BR>                Case "1/x"<BR>                    TextBox1.Text = 1 / CDbl(Label1.Text)<BR>            End Select<BR>            Label3.Text = "+"<BR>            Label1.Text = TextBox1.Text<BR>            Label4.Text = TextBox1.Text</P>
<P>        End If</P>
<P>    End Sub</P>
<P>    Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button13.Click<BR>        If Label2.Text = "" Then                          '减法的实现<BR>            Label3.Text = "-"<BR>            Label1.Text = TextBox1.Text<BR>            Label4.Text = TextBox1.Text<BR>        Else<BR>            Label2.Text = TextBox1.Text<BR>            Select Case Label3.Text<BR>                Case "+"<BR>                    TextBox1.Text = CDbl(Label1.Text) + CDbl(Label2.Text)<BR>                Case "*"<BR>                    TextBox1.Text = CDbl(Label1.Text) * CDbl(Label2.Text)<BR>                Case "-"<BR>                    TextBox1.Text = CDbl(Label1.Text) - CDbl(Label2.Text)<BR>                Case "/"<BR>                    TextBox1.Text = CDbl(Label1.Text) / CDbl(Label2.Text)<BR>                Case "1/x"<BR>                    TextBox1.Text = 1 / CDbl(Label1.Text)<BR>            End Select<BR>            Label3.Text = "-"<BR>            Label1.Text = TextBox1.Text<BR>            Label4.Text = TextBox1.Text</P>
<P>        End If<BR>    End Sub</P>
<P>    Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button14.Click<BR>        If Label2.Text = "" Then                      '乘法的实现<BR>            Label3.Text = "*"<BR>            Label1.Text = TextBox1.Text<BR>            Label4.Text = TextBox1.Text<BR>        Else<BR>            Label2.Text = TextBox1.Text<BR>            Select Case Label3.Text<BR>                Case "+"<BR>                    TextBox1.Text = CDbl(Label1.Text) + CDbl(Label2.Text)<BR>                Case "*"<BR>                    TextBox1.Text = CDbl(Label1.Text) * CDbl(Label2.Text)<BR>                Case "-"<BR>                    TextBox1.Text = CDbl(Label1.Text) - CDbl(Label2.Text)<BR>                Case "/"<BR>                    TextBox1.Text = CDbl(Label1.Text) / CDbl(Label2.Text)<BR>                Case "1/x"<BR>                    TextBox1.Text = 1 / CDbl(Label1.Text)<BR>            End Select<BR>            Label3.Text = "*"<BR>            Label1.Text = TextBox1.Text<BR>            Label4.Text = TextBox1.Text</P>
<P>        End If<BR>    End Sub</P>
<P>    Private Sub Button20_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button20.Click<BR>        Label2.Text = TextBox1.Text                     '等于的实现<BR>        Select Case Label3.Text<BR>            Case "+"<BR>                TextBox1.Text = CDbl(Label1.Text) + CDbl(Label2.Text)<BR>            Case "*"<BR>                TextBox1.Text = CDbl(Label1.Text) * CDbl(Label2.Text)<BR>            Case "-"<BR>                TextBox1.Text = CDbl(Label1.Text) - CDbl(Label2.Text)<BR>            Case "/"<BR>                TextBox1.Text = CDbl(Label1.Text) / CDbl(Label2.Text)<BR>            Case "1/x"<BR>                TextBox1.Text = 1 / CDbl(Label1.Text)<BR>        End Select<BR>        Label2.Text = ""<BR>    End Sub</P>
<P>    Private Sub Button16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button16.Click<BR>        If Label2.Text = "" Then                     '倒数的实现<BR>            Label3.Text = "1/x"<BR>            Label1.Text = TextBox1.Text<BR>            Label4.Text = TextBox1.Text<BR>        Else<BR>            Label2.Text = TextBox1.Text<BR>            Select Case Label3.Text<BR>                Case "+"<BR>                    TextBox1.Text = CDbl(Label1.Text) + CDbl(Label2.Text)<BR>                Case "*"<BR>                    TextBox1.Text = CDbl(Label1.Text) * CDbl(Label2.Text)<BR>                Case "-"<BR>                    TextBox1.Text = CDbl(Label1.Text) - CDbl(Label2.Text)<BR>                Case "/"<BR>                    TextBox1.Text = CDbl(Label1.Text) / CDbl(Label2.Text)<BR>                Case "1/x"<BR>                    TextBox1.Text = 1 / CDbl(Label1.Text)<BR>            End Select<BR>            Label3.Text = "1/x"<BR>            Label1.Text = TextBox1.Text<BR>            Label4.Text = TextBox1.Text</P>
<P>        End If<BR>    End Sub</P>
<P>    Private Sub Button18_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button18.Click<BR>        TextBox1.Text = ""                     'CE的实现<BR>    End Sub</P>
<P>    Private Sub Button19_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button19.Click<BR>        Label1.Text = ""                      ' C的实现<BR>        Label2.Text = ""<BR>        Label3.Text = ""<BR>        Label4.Text = ""<BR>        TextBox1.Text = ""<BR>    End Sub</P>
<P>    Private Sub Button17_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button17.Click<BR>        Dim s As String                          'Backspace的实现<BR>        Dim t As String<BR>        s = TextBox1.Text<BR>        t = Left(s, Len(s) - 1)<BR>        TextBox1.Text = t</P>
<P><BR>    End Sub</P>
<P>End Class<BR></P>

ocean_263 发表于 2005-11-20 00:51

给我邮箱 给你发过去

smoonmoon 发表于 2006-1-8 12:35

是呀给我你的邮箱我保证给你的是一个出错最少的程序<BR>是上学期没事的时候 写的

meiwang2008 发表于 2006-1-8 15:45

你写很不错吗?你今年大几了呢?你可以编一个《才数字》的吗?[em31]

jasonchen888 发表于 2006-1-9 17:19

我也要<a href="mailto:guobin609@163.com" target="_blank" >guobin609@163.com</A>  谢谢

zxb096 发表于 2006-1-11 22:58

我也要<a href="mailto:zxb096@163.com" target="_blank" ><FONT color=#000000>zxb096@163.com</FONT></A>  谢谢

meiwang2008 发表于 2006-1-14 22:48

你们就知道这样!!害得大哥在忙啊~<BR>大哥快编好了啊 ~~~~~~<BR>&lt;猜数字&gt;<BR>

xinfresh 发表于 2006-1-15 01:16

<P>编好了也不白费啊,一样可以拿来大家学习嘛</P>

furong 发表于 2006-1-16 11:33

<P>我也要<a href="mailto:.furong_63@163.com" target="_blank" >.furong_63@163.com</A>.谢谢!!!</P>

snakealpha 发表于 2006-1-17 10:25

好全呀,佩服

meiwang2008 发表于 2006-1-17 20:47

你们怎么不自己写啊

aaron6 发表于 2006-1-18 11:48

晕.楼主比我懒哦!

猴子啊 发表于 2006-4-24 21:10

要要要要要要,我要,<a href="mailto:568697407@QQ.com" target="_blank" >568697407@QQ.com</A>  谢谢!!!!!

jianeryinger 发表于 2006-5-4 13:58

这个计算器我们这个学期做过,你现在还要不要了?

linavy 发表于 2007-6-26 21:12

我也想要 程序啊 [em08]  <a href="mailto:lihaijun___@sohu.com" target="_blank" >lihaijun___@sohu.com</A>谢谢你哦[em22]

wopois 发表于 2007-7-1 22:48

<P>简单有复杂~</P>

daoliang 发表于 2007-10-29 11:22

非常感谢啊,代码我考回去研究研究啊

页: [1] 2

编程论坛