利用VB语言设计编程简易计算器,要求实现简单的加、减、乘、除计算操作。软件界面如下图所示

178504338@qq.com

第1个回答  2011-06-15
Dim Temp As Double
Dim D1, D2 As Integer
Dim T, P As Integer

Private Sub Command1_Click(Index As Integer)
If P = 0 Then
Text1.Text = Text1.Text & Command1(Index).Caption
D1 = Val(Text1.Text)
ElseIf P = 1 Then
Text2.Text = Text2.Text & Command1(Index).Caption
D2 = Val(Text2.Text)
End If
End Sub

Private Sub Command2_Click(Index As Integer)
P = 1
T = Index + 1
Label1.Caption = Command2(Index).Caption
End Sub

Private Sub Command3_Click()
P = 0
Select Case T
Case 1
Temp = D1 + D2
Case 2
Temp = D1 - D2
Case 3
Temp = D1 * D2
Case 4
Temp = D1 / D2
End Select
Text3.Text = Temp
End Sub

Private Sub Command4_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Label1.Caption = ""
Label2.Caption = ""
End Sub

Private Sub Form_Load()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Label1.Caption = ""
Label2.Caption = ""
End Sub
第2个回答  2011-06-14
给个邮箱发给你追问

178504338@qq.com

追答

已经发给你了

本回答被提问者采纳
第3个回答  2011-06-15
例如点击加号按钮的事件
private sub sum_click()
dim a as long
a=val(text1.text)+val(text2.text)
label1.caption=format(a,"0.000")
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编写计算器,要求实现加,减,乘,除,求乘方,正弦,余弦,正切,余...
基本思路如下,其他的触类旁通。Option Explicit 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 ...

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

如何用VB做一个简单计算器 要求实现加减乘除乘方开方功能
MsgBox "OK按钮被按下", vbDefaultButton1, "提示"End Sub快捷键大家一定都知道,在VB如何实现呢。其实很简单,在刚才的例子里在建立一个按钮Command1,把它的Caption属性设为Click &ME,如图4-11,在M的下面有一条下划线,运行程序,当你按下Alt+M的时候就触发了Command1_Click事件:Private Sub Command1_Click()M...

在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 ...

急急急,求大神用vb教做一个简易计算器,加减乘除就可以。能用加分
按你的要求做的代码如下:在1个新窗体上编排以下控件:添加1个Label1控件用作显示数据,name=lblScreen 添加1个Command控件数组(10个数字)用作输入数据的按钮0~9,name=cmdNumber,index=0~9 添加1个Command控件用作小数点按钮“.”,name=cmdPoint 添加1个Command控件等号按钮“=”,name=cmdEqual ...

用vb设计一个计算器,里面的加减乘除按键的代码怎么写
输入框.text = "" ' 等待下一个数值 select case sender.text ' 根据按下的按钮的文本属性确定你要做什么,这里可以用加减乘除号代替 case "加"操作 = "加"case "减"操作 = "减"case "乘"操作 = "乘"case "除"操作 = "除"end select end sub private sub 计算(byval sender a...

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编程设计一个类似于Windows附件中的计算器,如图所示,可进行简单的...
Dim pi As Double Dim temp As Double Dim j As Integer Dim te As String Dim yf As String Dim m As Boolean Dim f As Boolean Private Sub Command1_Click(Index As Integer)If f = True Then Text1 = ""If Index = 10 Then Text1.Text = Text1.Text & "."Else Text1.Text =...

利用VB编程设计一个类似于Windows附件中的计算器程序,要求可进行简单的...
Sub op()T1.Enabled = True T1.Visible = True T1.SetFocus End Sub Sub oi()T1.Enabled = False T1.Visible = False End Sub Private Sub Command1_Click()If O1 Then T5 = T1 + T3 ElseIf O2 Then T5 = T1 - T3 ElseIf O3 Then T5 = T1 * T3 ElseIf O4 Then If T3 = 0 ...

相似回答