利用VB语言设计编程简易计算器,要求实现简单的加、减、乘、除计算操作。

如题所述

第1个回答  2013-11-09
Option Explicit
Dim a As Integer, b As Integer, c As Integer, d As StringPrivate Sub cmd_0_Click()
txt_jg.Text = txt_jg.Text & "0"
End SubPrivate Sub cmd_1_Click()
txt_jg.Text = txt_jg.Text & "1"
End SubPrivate Sub cmd_2_Click()
txt_jg.Text = txt_jg.Text & "2"
End SubPrivate Sub cmd_3_Click()
txt_jg.Text = txt_jg.Text & "3"
End SubPrivate Sub cmd_4_Click()
txt_jg.Text = txt_jg.Text & "4"
End SubPrivate Sub cmd_5_Click()
txt_jg.Text = txt_jg.Text & "5"
End SubPrivate Sub cmd_6_Click()
txt_jg.Text = txt_jg.Text & "6"
End SubPrivate Sub cmd_7_Click()
txt_jg.Text = txt_jg.Text & "7"
End SubPrivate Sub cmd_8_Click()
txt_jg.Text = txt_jg.Text & "8"
End SubPrivate Sub cmd_9_Click()
txt_jg.Text = txt_jg.Text & "9"
End SubPrivate Sub cmd_cheng_Click()
a = Val(txt_jg.Text)
txt_jg.Text = txt_jg.Text & "*"
txt_jg.Text = ""
d = "*"
End SubPrivate Sub cmd_chu_Click()
a = Val(txt_jg.Text)
txt_jg.Text = txt_jg.Text & "/"
txt_jg.Text = ""
d = "/"
End SubPrivate Sub cmd_clear_Click()
txt_jg.Text = ""
End SubPrivate Sub cmd_denghao_Click()
b = Val(txt_jg.Text)
If d = "+" Then
c = a + b
ElseIf d = "-" Then
c = a - b
ElseIf d = "*" Then
c = a * b
ElseIf d = "/" Then
c = a / b
End If
txt_jg.Text = c
End SubPrivate Sub cmd_jia_Click()
a = Val(txt_jg.Text)
txt_jg.Text = txt_jg.Text & "+"
txt_jg.Text = ""
d = "+"
End SubPrivate Sub cmd_jian_Click()
a = Val(txt_jg.Text)
txt_jg.Text = txt_jg.Text & "-"
txt_jg.Text = ""
d = "-"
End Sub
望采纳,这个是仿windows的计算器
第2个回答  2013-11-09
我这有个模子,可能要根据你的需要改动下
第3个回答  2013-11-09
Dim a As Single, b As Single, x As Single
a = Val(Text1.Text)
b = Val(Text2.Text)
Label4.Caption = x
Private Sub Command1_Click()
x = a + b
End Sub

Private Sub Command2_Click()
x = a - b
End Sub

Private Sub Command3_Click()
x = a * b
End Sub

Private Sub Command4_Click()
x = a / b
End Sub

Private Sub Command5_Click()
Label4.Caption = ""
End Sub

vb:简易计算器(加减乘除)代码
代码如下:Dim t, t1 As Integer Dim x, y As Double Public Sub com()x = Val(l1.Caption)Select Case t1 Case Is = 1: y = y + x Case Is = 2: y = y - x Case Is = 3: y = y * x Case Is = 4: y = y \/ x End Select t1 = 0 t = 0 l1.Caption = "0"...

如何用VB编写计算器,要求实现加,减,乘,除,求乘方,正弦,余弦,正切,余...
Private StoredValue As Double Private Const opNone = 0 Private Const opAdd = 1 Private Const opSubtract = 2 Private Const opMultiply = 3 Private Const opDivide = 4 Private Operator As Integer Private NewEntry As Boolean ' Remove the last character.Private Sub DeleteCharacter()Dim...

用vb设计一个计算器,里面的加减乘除按键的代码怎么写
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 ' 根据按下的按钮...

用VB做一个简单的加减乘除的计算器,代码是什么?
我们现在首先要做的就是拉出Label,准备三个Label,把label1,label2,label3,这些改成第一个数、第二个数、结果。我们现在要text也要拉出三个,把了text里面text1、text2、text3全部删掉。我们现在要把command拉出四个,把里面command1-4都给成+-*\/ 现在我们现在要双击+,我们开始进行输入代码 ...

VB简易计算器编程至少能实现加减乘除运算,并具有清零键、退格键等功能...
Dim num As String ,num1 As String Dim Op As String Private Sub CmdNum_Click(Index As Integer)num=num+CmdNum(Index).Caption Label1.Caption=num End Sub Private Sub CmdOp_Click(Index As Index)num1=num Label1.Caption=""num=""Op=CmdOp(Index).Caption End Sub Private Sub Cmd...

在VB中计算器的代码(要求0到9的加减乘除运算)
'根据你的要求改了一下:'最简单的计算器(实现0到9的加减乘除运算)'1、添加Command1控件数组0~14 '2、设置Command1的Caption属性:'Command1(0~9) "0~9"'Command1(10~13) "+、-、*、\/"'Command1(14) "="'3、添加Text1控件 '排列好以上控件 Option Explicit Dim TTemp1, TTemp2 As ...

用VB2010编写一个简单计算器
方法\/步骤 打开VB新建一个EXE。如图画上4个按钮控件表示加减乘除,再画上3个文本控件表示两个数与和数,再画一个标签控件加入“=”号。当然,界面可以自己发挥。画好之后,就可以把控件进行命名,注意是属性栏的Caption项命名,以便运行的时候方便识别。好的,现在可以进行最重要的代码编写啦。双击对应...

VB6.0中,制作计算器时,如果要设加,减,乘,除,等于的命令是怎么样的
2、输入如下代码:Dim Num1, Num2 As Single Dim StrNum1, StrNum2 As String Dim FirstNum As Boolean Dim PointFlag As Boolean Dim Runsign As Integer Dim SignFlag As Boolean Private Sub Command1_Click(Index As Integer)Select Case Index Case 0 To 9 If FirstNum Then StrNum1 =...

如何用VB做一个简单计算器 要求实现加减乘除乘方开方功能
在编写程序之前,我们先来回顾一下计算器的使用。 按下数字键在液晶屏上会出现数字,这是最基本的功能。 第一次按下运算键,再按下数字键,将重新输入第二个数字,再次按下运算键,将算出前两个数的结果,然后按下数字键,将又重新输入新的数字。 输入数字后,按下“等于键”将仍输出原来的数字,输入运算符和第二...

VB 编制一模拟计算器,可计算+,-,*,\/,要求输入两个操作数和一个操作...
Dim ct1 As Integer Dim ct2 As Integer Dim n As Single Dim beiss As Boolean Private Sub baifen_Click()Text1 = Text1 & "%"If beiss = True Then Text1 = 0: beiss = False End Sub Private Sub Chen_Click()Label1.Caption = "*"n = Val(Text1.Text)beiss = True End Sub...

相似回答
大家正在搜