vb.net做计算机器 计算机编程语言vb

有关vb.net制作计算器的问题

判断吧,如果点击+按钮,则一个全局变量为1,-按钮,则全局变量为2.以此类推,然后if或case判断哪个数,如果为1,就两个数相加。

在齐齐哈尔等地区,都构建了全面的区域性战略布局,加强发展的系统性、市场前瞻性、产品创新能力,以专注、极致的服务理念,为客户提供成都网站建设、成都网站设计 网站设计制作定制设计,公司网站建设,企业网站建设,成都品牌网站建设,营销型网站,外贸网站建设,齐齐哈尔网站建设费用合理。

用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

Me.Button9 = New System.Windows.Forms.Button

Me.Button10 = New System.Windows.Forms.Button

Me.Button11 = New System.Windows.Forms.Button

Me.Button12 = New System.Windows.Forms.Button

Me.Button13 = New System.Windows.Forms.Button

Me.Button14 = New System.Windows.Forms.Button

Me.Button15 = New System.Windows.Forms.Button

Me.Button16 = New System.Windows.Forms.Button

Me.SuspendLayout()

'

'Label1

'

Me.Label1.Location = New System.Drawing.Point(16, 16)

Me.Label1.Name = "Label1"

Me.Label1.Size = New System.Drawing.Size(48, 16)

Me.Label1.TabIndex = 0

Me.Label1.Text = "结果:"

'

'TextBox1

'

Me.TextBox1.Location = New System.Drawing.Point(64, 8)

Me.TextBox1.Name = "TextBox1"

Me.TextBox1.Size = New System.Drawing.Size(120, 21)

Me.TextBox1.TabIndex = 1

Me.TextBox1.Text = ""

'

'Button1

'

Me.Button1.Location = New System.Drawing.Point(200, 8)

Me.Button1.Name = "Button1"

Me.Button1.Size = New System.Drawing.Size(56, 24)

Me.Button1.TabIndex = 2

Me.Button1.Text = "清空"

'

'Button2

'

Me.Button2.Location = New System.Drawing.Point(48, 56)

Me.Button2.Name = "Button2"

Me.Button2.Size = New System.Drawing.Size(24, 24)

Me.Button2.TabIndex = 3

Me.Button2.Text = "1"

'

'Button3

'

Me.Button3.Location = New System.Drawing.Point(88, 56)

Me.Button3.Name = "Button3"

Me.Button3.Size = New System.Drawing.Size(24, 24)

Me.Button3.TabIndex = 4

Me.Button3.Text = "2"

'

'Button4

'

Me.Button4.Location = New System.Drawing.Point(136, 56)

Me.Button4.Name = "Button4"

Me.Button4.Size = New System.Drawing.Size(24, 24)

Me.Button4.TabIndex = 5

Me.Button4.Text = "3"

'

'Button5

'

Me.Button5.Location = New System.Drawing.Point(48, 88)

Me.Button5.Name = "Button5"

Me.Button5.Size = New System.Drawing.Size(24, 24)

Me.Button5.TabIndex = 6

Me.Button5.Text = "4"

'

'Button6

'

Me.Button6.Location = New System.Drawing.Point(88, 88)

Me.Button6.Name = "Button6"

Me.Button6.Size = New System.Drawing.Size(24, 24)

Me.Button6.TabIndex = 7

Me.Button6.Text = "5"

'

'Button7

'

Me.Button7.Location = New System.Drawing.Point(136, 88)

Me.Button7.Name = "Button7"

Me.Button7.Size = New System.Drawing.Size(24, 24)

Me.Button7.TabIndex = 8

Me.Button7.Text = "6"

'

'Button8

'

Me.Button8.Location = New System.Drawing.Point(48, 120)

Me.Button8.Name = "Button8"

Me.Button8.Size = New System.Drawing.Size(24, 24)

Me.Button8.TabIndex = 9

Me.Button8.Text = "7"

'

'Button9

'

Me.Button9.Location = New System.Drawing.Point(88, 120)

Me.Button9.Name = "Button9"

Me.Button9.Size = New System.Drawing.Size(24, 24)

Me.Button9.TabIndex = 10

Me.Button9.Text = "8"

'

'Button10

'

Me.Button10.Location = New System.Drawing.Point(136, 120)

Me.Button10.Name = "Button10"

Me.Button10.Size = New System.Drawing.Size(24, 24)

Me.Button10.TabIndex = 11

Me.Button10.Text = "9"

'

'Button11

'

Me.Button11.Location = New System.Drawing.Point(48, 152)

Me.Button11.Name = "Button11"

Me.Button11.Size = New System.Drawing.Size(24, 24)

Me.Button11.TabIndex = 12

Me.Button11.Text = "0"

'

'Button12

'

Me.Button12.Location = New System.Drawing.Point(176, 56)

Me.Button12.Name = "Button12"

Me.Button12.Size = New System.Drawing.Size(24, 24)

Me.Button12.TabIndex = 13

Me.Button12.Text = "+"

'

'Button13

'

Me.Button13.Location = New System.Drawing.Point(176, 88)

Me.Button13.Name = "Button13"

Me.Button13.Size = New System.Drawing.Size(24, 24)

Me.Button13.TabIndex = 14

Me.Button13.Text = "-"

'

'Button14

'

Me.Button14.Location = New System.Drawing.Point(176, 120)

Me.Button14.Name = "Button14"

Me.Button14.Size = New System.Drawing.Size(24, 24)

Me.Button14.TabIndex = 15

Me.Button14.Text = "*"

'

'Button15

'

Me.Button15.Location = New System.Drawing.Point(176, 152)

Me.Button15.Name = "Button15"

Me.Button15.Size = New System.Drawing.Size(24, 24)

Me.Button15.TabIndex = 16

Me.Button15.Text = "/"

'

'Button16

'

Me.Button16.Location = New System.Drawing.Point(88, 152)

Me.Button16.Name = "Button16"

Me.Button16.Size = New System.Drawing.Size(72, 24)

Me.Button16.TabIndex = 17

Me.Button16.Text = "计算"

'

'SimpleCalculator

'

Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)

Me.ClientSize = New System.Drawing.Size(264, 190)

Me.Controls.Add(Me.Button16)

Me.Controls.Add(Me.Button15)

Me.Controls.Add(Me.Button14)

Me.Controls.Add(Me.Button13)

Me.Controls.Add(Me.Button12)

Me.Controls.Add(Me.Button11)

Me.Controls.Add(Me.Button10)

Me.Controls.Add(Me.Button9)

Me.Controls.Add(Me.Button8)

Me.Controls.Add(Me.Button7)

Me.Controls.Add(Me.Button6)

Me.Controls.Add(Me.Button5)

Me.Controls.Add(Me.Button4)

Me.Controls.Add(Me.Button3)

Me.Controls.Add(Me.Button2)

Me.Controls.Add(Me.Button1)

Me.Controls.Add(Me.TextBox1)

Me.Controls.Add(Me.Label1)

Me.Name = "SimpleCalculator"

Me.Text = "简单计算器"

Me.ResumeLayout(False)

End Sub

#End Region

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)

End Sub

Private Sub TextBox1_TabStopChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

Dim btn As Button '按钮类型的变量

btn = sender '把产生该事件的按钮对象赋值给btn

TextBox1.Text = TextBox1.Text + btn.Text '把该按钮的Text属性值连接到TextBox1中

End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

Dim btn As Button

btn = sender

TextBox1.Text += btn.Text

End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

Dim btn As Button

btn = sender

TextBox1.Text += btn.Text

End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click

Dim btn As Button

btn = sender

TextBox1.Text += btn.Text

End Sub

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click

Dim btn As Button

btn = sender

TextBox1.Text += btn.Text

End Sub

Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click

Dim btn As Button

btn = sender

TextBox1.Text += btn.Text

End Sub

Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click

Dim btn As Button

btn = sender

TextBox1.Text += btn.Text

End Sub

Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click

Dim btn As Button

btn = sender

TextBox1.Text += btn.Text

End Sub

Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click

Dim btn As Button

btn = sender

TextBox1.Text += btn.Text

End Sub

Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click

Dim btn As Button

btn = sender

TextBox1.Text += btn.Text

End Sub

Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click

Dim btn As Button

btn = sender

'在文本框的Text属性后连接一个空格、本按钮的Text属性值和一个空格

TextBox1.Text = TextBox1.Text + " " + btn.Text + " "

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

TextBox1.Text = "" '清空文本框

End Sub

Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button13.Click

Dim btn As Button

btn = sender

TextBox1.Text = TextBox1.Text + " " + btn.Text + " "

End Sub

Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button14.Click

Dim btn As Button

btn = sender

TextBox1.Text = TextBox1.Text + " " + btn.Text + " "

End Sub

Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button15.Click

Dim btn As Button

btn = sender

TextBox1.Text = TextBox1.Text + " " + btn.Text + " "

End Sub

Private Sub Button16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button16.Click

'发生错误转移到标号“ErrorPro”指定的行去执行错误处理程序

On Error GoTo ErrorPro

Dim r As Decimal '保存计算结果的变量

Dim t As String = TextBox1.Text '用于保存文本框中的算术表达式

Dim space As Integer = t.IndexOf(" ") '搜索空格位置,如果没有空格,返回值为0

'字符串的取子符方法,第二个参数小于0,则将产生错误号为5的异常,即过程参数不正确

Dim s1 As String = t.Substring(0, space) '通过取子串方法获得第一个运算数

Dim op As String = t.Substring(space + 1, 1) '通过取子串方法获得运算符

Dim s2 As String = t.Substring(space + 3) '通过取子串方法获得第二个运算数

Dim arg1, arg2 As Integer

arg1 = Val(s1) : arg2 = Val(s2)

Select Case op

Case "+" : r = arg1 + arg2

Case "-" : r = arg1 - arg2

Case "*" : r = arg1 * arg2

Case "/" : r = arg1 / arg2

Case Else

MsgBox("输入的运算符有误!")

Exit Sub

End Select

TextBox1.Text = CStr(r) '显示结果

Exit Sub '退出过程

ErrorPro: '错误处理程序块

Select Case Err.Number

Case 6 '除数为零时,或运算溢出时的错误号

MsgBox("算术运算溢出!", , "溢出提示")

TextBox1.Focus()

Exit Sub

Case 5 ' Substring过程的参数不符合要求的错误号

MsgBox("必须输入运算符和第二个运算数!", , "运算数少")

Exit Sub

Case Else

'其它情况显示错误号和错误原因

MsgBox("错误号为" Err.Number Chr(10) Chr(13) "错误原因:" Err.Description)

Exit Sub

End Select

End Sub

End Class

如何编辑计算器功能的应用程序?

Visual Studio2008发布后,有大量的VB.net爱好者抛弃原来的Visual Studio2005平台转向现在流行的Visual Studio2008平台。但是Visual Studio2008有一个缺点就是需要比较高的硬件配置才能正常平稳的运行,所以到现在为止还有一部分人处于观望中,并没有转向这个平台。然而Visual Studio2008的一些新的功能以及优化性比先前版本有了很大的进步。本篇文章将主要介绍怎样利用VB.net去编写一个计算器程序,程序虽然不复杂,但是其中所运用的知识和代码非常具有代表性,在平时开发中也是经常需要用到的。希望对VB.net2008的初学者带来帮助。

打开 Visual Studio 2008。在文件 (File) 菜单上,单击新建项目 (New Project)。 在新建项目 (New Project) 对话框的模板 (Templates) 窗格中,单击 Windows 应用程序(Windows Application)。单击确定 (OK)。

在Form1窗体中添加一个TextBox1控件和19个Button按钮,详细属性设置请查看以下的表格。

用VB设计一个计算器

'这个很简单的了,你用记事本把这段代码复制过去,然后另存为.frm就可以了

'然后用vb打开。看看效果。

'以下保存为 任务名称.frm

VERSION 5.00

Begin VB.Form Form1

Caption = "计算机"

ClientHeight = 4230

ClientLeft = 60

ClientTop = 750

ClientWidth = 3165

LinkTopic = "Form1"

MaxButton = 0 'False

MinButton = 0 'False

ScaleHeight = 4230

ScaleWidth = 3165

StartUpPosition = 2 '屏幕中心

Begin VB.Frame Frame1

Height = 3495

Left = 120

TabIndex = 1

Top = 600

Width = 2895

Begin VB.CommandButton cmdResult

Caption = "="

BeginProperty Font

Name = "宋体"

Size = 12

Charset = 134

Weight = 400

Underline = 0 'False

Italic = 0 'False

Strikethrough = 0 'False

EndProperty

Height = 375

Left = 1080

TabIndex = 20

Top = 3000

Width = 1695

End

Begin VB.CommandButton cmdOff

Caption = "OFF"

Height = 375

Left = 1560

TabIndex = 19

Top = 240

Width = 495

End

Begin VB.CommandButton cmdCE

Caption = "CE"

Height = 375

Left = 2280

TabIndex = 18

Top = 240

Width = 495

End

Begin VB.CommandButton cmdchu

Caption = "/"

Height = 375

Left = 2280

TabIndex = 17

Top = 2520

Width = 495

End

Begin VB.CommandButton cmdjia

Caption = "+"

Height = 375

Left = 2280

TabIndex = 16

Top = 720

Width = 495

End

Begin VB.CommandButton cmd0

Caption = "0"

Height = 375

Left = 840

TabIndex = 15

Top = 2520

Width = 495

End

Begin VB.CommandButton cmd6

Caption = "6"

Height = 375

Left = 1560

TabIndex = 14

Top = 1320

Width = 495

End

Begin VB.CommandButton cmd8

Caption = "8"

Height = 375

Left = 840

TabIndex = 13

Top = 720

Width = 495

End

Begin VB.CommandButton cmd4

Caption = "4"

Height = 375

Left = 120

TabIndex = 12

Top = 1320

Width = 495

End

Begin VB.CommandButton cmd9

Caption = "9"

Height = 375

Left = 1560

TabIndex = 11

Top = 720

Width = 495

End

Begin VB.CommandButton cmd2

Caption = "2"

Height = 375

Left = 840

TabIndex = 10

Top = 1920

Width = 495

End

Begin VB.CommandButton cmdjian

Caption = "-"

Height = 375

Left = 2280

TabIndex = 9

Top = 1320

Width = 495

End

Begin VB.CommandButton cmdPoint

Caption = "."

BeginProperty Font

Name = "宋体"

Size = 12

Charset = 134

Weight = 400

Underline = 0 'False

Italic = 0 'False

Strikethrough = 0 'False

EndProperty

Height = 375

Left = 1560

TabIndex = 8

Top = 2520

Width = 495

End

Begin VB.CommandButton cmdcheng

Caption = "*"

Height = 375

Left = 2280

TabIndex = 7

Top = 1920

Width = 495

End

Begin VB.CommandButton cmd5

Caption = "5"

Height = 375

Left = 840

TabIndex = 6

Top = 1320

Width = 495

End

Begin VB.CommandButton cmd3

Caption = "3"

Height = 375

Left = 1560

TabIndex = 5

Top = 1905

Width = 495

End

Begin VB.CommandButton cmd1

Caption = "1"

Height = 375

Left = 120

TabIndex = 4

Top = 1920

Width = 495

End

Begin VB.CommandButton cmd7

Caption = "7"

Height = 375

Left = 120

TabIndex = 3

Top = 720

Width = 495

End

Begin VB.CommandButton cmdChange

Caption = "+/-"

Height = 375

Left = 120

TabIndex = 2

Top = 2520

Width = 495

End

End

Begin VB.TextBox txt

Alignment = 1 'Right Justify

Enabled = 0 'False

BeginProperty Font

Name = "宋体"

Size = 10.5

Charset = 134

Weight = 400

Underline = 0 'False

Italic = 0 'False

Strikethrough = 0 'False

EndProperty

Height = 375

Left = 120

Locked = -1 'True

TabIndex = 0

Top = 120

Width = 2895

End

Begin VB.Menu meuFile

Caption = "文件(F)"

Begin VB.Menu meuExit

Caption = "退出(X)"

Shortcut = ^X

End

End

End

Attribute VB_Name = "Form1"

Attribute VB_GlobalNameSpace = False

Attribute VB_Creatable = False

Attribute VB_PredeclaredId = True

Attribute VB_Exposed = False

Dim XiaoShu As Boolean

'在窗体变量中声明一个布尔值来判断是否按下了小数点键,防止txt中出现多个小数。如果已经输入了小数点则Xiaoshu为True,否则为False

Dim FuHao As Byte

'声明一个Byte来记录我们按下了什么符号,1为"+",2为"-",3为"*",4为"/"

Dim FirstNumber As Double

'声明一个变量来记录操作数的第一个数,如A+B,那么FirstNumber来记下A的值。

Dim DengHao As Boolean

'声明一个变量来记录是否按下了=号,如果按下了则为True

Private Sub cmd0_Click()

If txt.Text "" Then txt.Text = txt.Text + "0" '防止多个0在文本中出现

End Sub

Private Sub cmd1_Click() '按下1时

If Not DengHao Then '没按下等号

txt.Text = txt.Text + "1"

Else

txt.Text = "1" '按下了等号

DengHao = False

End If

End Sub

Private Sub cmd2_Click() '按下2时

If Not DengHao Then '没按下等号

txt.Text = txt.Text + "2"

Else

txt.Text = "2" '按下了等号

DengHao = False

End If

End Sub

Private Sub cmd3_click() '按下3时

If Not DengHao Then '没按下等号

txt.Text = txt.Text + "3"

Else

txt.Text = "3" '按下了等号

DengHao = False

End If

End Sub

Private Sub cmd4_Click() '按下4时

If Not DengHao Then '没按下等号

txt.Text = txt.Text + "4"

Else

txt.Text = "4" '按下了等号

DengHao = False

End If

End Sub

Private Sub cmd5_Click() '按下5时

If Not DengHao Then '没按下等号

txt.Text = txt.Text + "5"

Else

txt.Text = "5" '按下了等号

DengHao = False

End If

End Sub

Private Sub cmd6_Click() '按下6时

If Not DengHao Then '没按下等号

txt.Text = txt.Text + "6"

Else

txt.Text = "6" '按下了等号

DengHao = False

End If

End Sub

Private Sub cmd7_Click() '按下7时

If Not DengHao Then '没按下等号

txt.Text = txt.Text + "7"

Else

txt.Text = "7" '按下了等号

DengHao = False

End If

End Sub

Private Sub cmd8_Click() '按下8时

If Not DengHao Then '没按下等号

txt.Text = txt.Text + "8"

Else

txt.Text = "8" '按下了等号

DengHao = False

End If

End Sub

Private Sub cmd9_Click() '按下9时

If Not DengHao Then '没按下等号

txt.Text = txt.Text + "9"

Else

txt.Text = "9" '按下了等号

DengHao = False

End If

End Sub

Private Sub cmdCE_Click()

txt.Text = ""

XiaoShu = False

End Sub

Private Sub cmdChange_Click()

If (Sgn(Val(txt.Text))) = 1 Then txt.Text = "-" + txt.Text: Exit Sub '用Sgn来判断txt文本框内的值的符号。大于0的话就在前面加上"-"

If (Sgn(Val(txt.Text))) = -1 Then txt.Text = Abs(Val(txt.Text)) 'txt文本框的文本为大于0的数txt前面的"-"去掉。

End Sub

Private Sub cmdcheng_Click()

FirstNumber = Val(txt.Text)

FuHao = 3

txt.Text = ""

XiaoShu = False

End Sub

Private Sub cmdchu_Click()

FirstNumber = Val(txt.Text)

FuHao = 4

txt.Text = ""

XiaoShu = False

End Sub

Private Sub cmdjia_Click()

FirstNumber = Val(txt.Text)

FuHao = 1

txt.Text = ""

XiaoShu = False

End Sub

Private Sub cmdjian_Click()

FirstNumber = Val(txt.Text)

FuHao = 2

txt.Text = ""

XiaoShu = False

End Sub

Private Sub cmdOff_Click()

End

End Sub

Private Sub cmdPoint_Click()

If txt.Text = "" Then txt.Text = "0"

If Not XiaoShu Then '当我们以前没有按下小数点键时在txt中加上小数点

txt.Text = txt.Text + "."

XiaoShu = True

End If

End Sub

Private Sub cmdResult_Click()

If FuHao = 1 Then '按下了+号

txt.Text = FirstNumber + Val(txt.Text)

End If

If FuHao = 2 Then '按下了-号

txt.Text = FirstNumber - Val(txt.Text)

End If

If FuHao = 3 Then '按下了*号

txt.Text = FirstNumber * Val(txt.Text)

End If

If FuHao = 4 Then '按下了、号

txt.Text = FirstNumber / Val(txt.Text)

End If

DengHao = True '记录下按了=号

XiaoShu = False

End Sub

Private Sub meuExit_Click()

End

End Sub

如何用VB.NET编写计算器

简单的说拖出一些控件,设置相应的caption和属性等等,双击每个button控件,进行相应的处理,即可

怎么用VB.NET来编一个简单计算机的程序,代码怎么写?

创建一个工程

添加一个按扭

双击按扭

输入如下

msgbox ("Hello World!")

按F5

所有的可视开发工具基本都是这个流程,关键还是要学相关语言标准。


分享名称:vb.net做计算机器 计算机编程语言vb
链接分享:http://pwwzsj.com/article/docjips.html