Vbnet计算器代码 vb写计算器代码

用vb设计一个计算器,里面的加减乘除按键的代码怎么写简单点的:
dim 上一个数 as double
dim 下一个数 as double
dim 结果 as double
dim 操作 as string
private sub 加减乘除(byval sender as object, byval e as eventargs) handles 加.click, 减.click, 乘.click, 除.click
上一个数 = cdbl(输入框.text)' 存储当前输入的数值
输入框.text = ""' 等待下一个数值
select case sender.text' 根据按下的按钮的文本属性确定你要做什么,这里可以用加减乘除号代替
case "加"
操作 = "加"
case "减"
操作 = "减"
case "乘"
操作 = "乘"
case "除"
操作 = "除"
end select
end sub
private sub 计算(byval sender as object, byval e as eventargs) handles 等号.click
下一个数 = 输入框.text
输入框.text = ”“
select case 操作
case "加"
结果 = 上一个数 + 下一个数
case "减"
结果 = 上一个数 - 下一个数
case "乘"
结果 = 上一个数 * 下一个数
case "除"
结果 = 上一个数 / 下一个数
end select
输入框.text = cstr(结果)
上一个数 = 结果
end sub
.NET 的哈,我没有 .NET 现在 , 不知道行不行
用VB.NET编的计算器程序!Public Class SimpleCalculator
Inherits System.Windows.Forms.Form
#Region " Windows 窗体设计器生成的代码 "
Public Sub New()
MyBase.New()
'该调用是 Windows 窗体设计器所必需的 。
InitializeComponent()
'在 InitializeComponent() 调用之后添加任何初始化
End Sub
'窗体重写处置以清理组件列表 。
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Windows 窗体设计器所必需的
Private components As System.ComponentModel.IContainer
'注意:以下过程是 Windows 窗体设计器所必需的
'可以使用 Windows 窗体设计器修改此过程 。
'不要使用代码编辑器修改它 。
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents Button3 As System.Windows.Forms.Button
Friend WithEvents Button4 As System.Windows.Forms.Button
Friend WithEvents Button5 As System.Windows.Forms.Button
Friend WithEvents Button6 As System.Windows.Forms.Button
Friend WithEvents Button7 As System.Windows.Forms.Button
Friend WithEvents Button8 As System.Windows.Forms.Button
Friend WithEvents Button9 As System.Windows.Forms.Button
Friend WithEvents Button10 As System.Windows.Forms.Button
Friend WithEvents Button11 As System.Windows.Forms.Button
Friend WithEvents Button12 As System.Windows.Forms.Button
Friend WithEvents Button13 As System.Windows.Forms.Button
Friend WithEvents Button14 As System.Windows.Forms.Button
Friend WithEvents Button15 As System.Windows.Forms.Button
Friend WithEvents Button16 As System.Windows.Forms.Button
System.Diagnostics.DebuggerStepThrough() Private Sub InitializeComponent()
Me.Label1 = New System.Windows.Forms.Label
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.Button1 = New System.Windows.Forms.Button
Me.Button2 = New System.Windows.Forms.Button
Me.Button3 = New System.Windows.Forms.Button
Me.Button4 = New System.Windows.Forms.Button
Me.Button5 = New System.Windows.Forms.Button
Me.Button6 = New System.Windows.Forms.Button
Me.Button7 = New System.Windows.Forms.Button
Me.Button8 = New System.Windows.Forms.Button

推荐阅读