使用模拟软件做一个计算器,要求能做简单的加减乘除操作. 加号和减号键同时按下,要在计算器上显示自己的学号。
我给你代码,加号和减号同时点击下可以显示学号,示例学号为6710
求邮箱,我发给你
这是我以前做的计算器改了一下的(先要输入数字,后才点击+-,且不可恢复,须关闭程序才可恢复)
Dim xsd, FLAG As Boolean
Dim sf As Integer
Dim ds1, ds2, jg1 As Single
Private Sub Command1_Click(Index As Integer)
Me.Text1.Text = Me.Text1.Text & CStr(Index)
End Sub
Private Sub Command2_Click()
ds2 = CSng(Me.Text1.Text)
Me.Text1.Text = ""
Select Case sf
Case 1
jg1 = ds1 + ds2
Me.Text1.Text = CStr(jg1)
ds1 = jg1
ds2 = 0
Case 2
jg1 = ds1 - ds2
Me.Text1.Text = CStr(jg1)
ds1 = jg1
ds2 = 0
Case 3
jg1 = ds1 * ds2
Me.Text1.Text = CStr(jg1)
ds1 = jg1
ds2 = 0
Case 4
If ds2 = 0 Then Exit Sub
jg1 = ds1 / ds2
Me.Text1.Text = CStr(jg1)
ds1 = jg1
ds2 = 0
End Select
End Sub
Private Sub Command3_Click()
FLAG = True
Me.Command3.Enabled = False
ds1 = CSng(Me.Text1.Text)
Me.Text1.Text = ""
sf = 1
End Sub
Private Sub Command4_Click()
If FLAG = False Then
ds1 = CSng(Me.Text1.Text)
Me.Text1.Text = ""
sf = 2
Else
Me.Text1.Text = "6710"
Me.Command3.Enabled = False
End If
End Sub
Private Sub Command5_Click()
ds1 = CSng(Me.Text1.Text)
Me.Text1.Text = ""
sf = 3
End Sub
Private Sub Command6_Click()
ds1 = CSng(Me.Text1.Text)
Me.Text1.Text = ""
sf = 4
End Sub
Private Sub Command7_Click()
If xsd = False Then
Me.Text1.Text = Me.Text1.Text & "."
xsd = True
Else
Exit Sub
End If
End Sub
Private Sub Command8_Click()
ds1 = 0
ds2 = 0
jg1 = 0
xsd = False
sf = 0
Me.Text1.Text = ""
End Sub
Private Sub Form_Load()
For i = 0 To 9
Me.Command1(i).Caption = CStr(i)
Next i
End Sub
图片:
...加号和减号键同时按下,计算器上显示自己的学号。
Dim xsd, FLAG As Boolean Dim sf As Integer Dim ds1, ds2, jg1 As Single Private Sub Command1_Click(Index As Integer)Me.Text1.Text = Me.Text1.Text & CStr(Index)End Sub Private Sub Command2_Click()ds2 = CSng(Me.Text1.Text)Me.Text1.Text = ""Select Case sf Case 1 j...
如何用VB做一个简单计算器 要求实现加减乘除乘方开方功能
Case 1: Text1.Text = Data + Val(Text1.Text) Case 2: Text1.Text = Data - Val(Text1.Text) Case 3: Text1.Text = Data * Val(Text1.Text) Case 4: If Val(Text1.Text) = 0 Then MsgBox "除数不等于0": Exit Sub Else Text1.Text = Data \/ Val(Text1.Text) Case 5: Text1.Text...
用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:简易计算器(加减乘除)代码
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"End Sub ...
用VB2010编写一个简单计算器
方法\/步骤 打开VB新建一个EXE。如图画上4个按钮控件表示加减乘除,再画上3个文本控件表示两个数与和数,再画一个标签控件加入“=”号。当然,界面可以自己发挥。画好之后,就可以把控件进行命名,注意是属性栏的Caption项命名,以便运行的时候方便识别。好的,现在可以进行最重要的代码编写啦。双击对应...
vb编写计算器加减乘除怎么弄
Dim NumOps As Integer ' 操作数个数。Dim LastInput ' 指示上一次按键事件的类型。Dim OpFlag ' 指示未完成的操作。Dim TempReadout' C (取消) 按钮的 Click 事件过程' 重新设置显示并初始化变量。Private Sub Cancel_Click() Readout = Format(0, "0.") Op1 = 0 Op2 ...
用VB编写一个计算器程序的代码
2、各控件组其属性设置如下:设置效果如下图所示:二、编写代码 Dim s1 As Single, s2 As Single, ysf As String ‘定义两个单精度数变量用与存放参与运算的数,一个字符型存放运算符 Private Sub Command1_Click(Index As Integer)Text1.Text = Text1.Text & Command1(Index).Caption ’...
用VB做一个简单的加减乘除的计算器,代码是什么?
我们现在要text也要拉出三个,把了text里面text1、text2、text3全部删掉。我们现在要把command拉出四个,把里面command1-4都给成+-*\/ 现在我们现在要双击+,我们开始进行输入代码 在里面我们现在要:text3.text=val(text1.text)+val(text2.text)我们要把这个(text3.text=val(text1.text)+val(...
VB简易计算器编程至少能实现加减乘除运算,并具有清零键、退格键等功能...
Label1.Caption=""num=""Op=CmdOp(Index).Caption End Sub Private Sub CmdEq_Click()Select Case Op Case "+"num=CStr(Val(num1)+Val(num))Case "-"num=CStr(Val(num1)-Val(num))Case "*"num=CStr(Val(num1)*Val(num))Case "\/"num=CStr(Val(num1)\/Val(num))End Select Label...
急急急,求大神用vb教做一个简易计算器,加减乘除就可以。能用加分
按你的要求做的代码如下:在1个新窗体上编排以下控件:添加1个Label1控件用作显示数据,name=lblScreen 添加1个Command控件数组(10个数字)用作输入数据的按钮0~9,name=cmdNumber,index=0~9 添加1个Command控件用作小数点按钮“.”,name=cmdPoint 添加1个Command控件等号按钮“=”,name=cmdEqual ...