用vb编写一个简单计算器的程序
label1是最大的那个框子label2是label1最左边显示加减乘除符号的框子label3是label1最右边显示结果这个程序编写出来以后,一按等于,label3中出...
label1 是最大的那个框子
label2 是label1最左边显示加减乘除符号的框子
label3 是label1最右边显示结果
这个程序编写出来以后,一按等于,label3中出现label1中的数字
Private Sub Command1_Click()Label1.Caption = Label1.Caption & "1"End Sub
Private Sub Command11_Click()Label1.Caption = ""Label2.Caption = ""End SubPrivate Sub Command12_Click()Unload MeEnd SubPrivate Sub Command13_Click()A = Label1.CaptionLabel2.Caption = "+"Label1.Caption = ""End SubPrivate Sub Command14_Click()A = Label1.CaptionLabel2.Caption = "-"Label1.Caption = ""End SubPrivate Sub Command15_Click()A = Label1.CaptionLabel2.Caption = "×"Label1.Caption = ""End SubPrivate Sub Command16_Click()A = Label1.CaptionLabel2.Caption = "÷"Label1.Caption = ""End Sub
Private Sub Command17_Click()B = Val(Label1.Caption)If Label2.Caption = "+" ThenLabel3.Caption = Val(A) + Val(B)Else If Label2.Caption = "-" Then Label3.Caption = Val(A) - Val(B) Else If Label2.Caption = "×" Then Label3.Caption = Val(A) * Val(B) Else Label3.Caption = Val(A) / Val(B) End If End IfEnd IfEnd Sub
Private Sub Command18_Click()Label1.Caption = Label1.Caption & "0"End SubPrivate Sub Command19_Click()Label1.Caption = Val(Label1.Caption) & "."End SubPrivate Sub Command2_Click()Label1.Caption = Label1.Caption & "2"End SubPrivate Sub Command3_Click()Label1.Caption = Label1.Caption & "3"End SubPrivate Sub Command4_Click()Label1.Caption = Label1.Caption & "4"End SubPrivate Sub Command5_Click()Label1.Caption = Label1.Caption & "5"End SubPrivate Sub Command6_Click()Label1.Caption = Label1.Caption & "6"End SubPrivate Sub Command7_Click()Label1.Caption = Label1.Caption & "7"End SubPrivate Sub Command8_Click()Label1.Caption = Label1.Caption & "8"End SubPrivate Sub Command9_Click()Label1.Caption = Label1.Caption & "9"End Sub 展开
label2 是label1最左边显示加减乘除符号的框子
label3 是label1最右边显示结果
这个程序编写出来以后,一按等于,label3中出现label1中的数字
Private Sub Command1_Click()Label1.Caption = Label1.Caption & "1"End Sub
Private Sub Command11_Click()Label1.Caption = ""Label2.Caption = ""End SubPrivate Sub Command12_Click()Unload MeEnd SubPrivate Sub Command13_Click()A = Label1.CaptionLabel2.Caption = "+"Label1.Caption = ""End SubPrivate Sub Command14_Click()A = Label1.CaptionLabel2.Caption = "-"Label1.Caption = ""End SubPrivate Sub Command15_Click()A = Label1.CaptionLabel2.Caption = "×"Label1.Caption = ""End SubPrivate Sub Command16_Click()A = Label1.CaptionLabel2.Caption = "÷"Label1.Caption = ""End Sub
Private Sub Command17_Click()B = Val(Label1.Caption)If Label2.Caption = "+" ThenLabel3.Caption = Val(A) + Val(B)Else If Label2.Caption = "-" Then Label3.Caption = Val(A) - Val(B) Else If Label2.Caption = "×" Then Label3.Caption = Val(A) * Val(B) Else Label3.Caption = Val(A) / Val(B) End If End IfEnd IfEnd Sub
Private Sub Command18_Click()Label1.Caption = Label1.Caption & "0"End SubPrivate Sub Command19_Click()Label1.Caption = Val(Label1.Caption) & "."End SubPrivate Sub Command2_Click()Label1.Caption = Label1.Caption & "2"End SubPrivate Sub Command3_Click()Label1.Caption = Label1.Caption & "3"End SubPrivate Sub Command4_Click()Label1.Caption = Label1.Caption & "4"End SubPrivate Sub Command5_Click()Label1.Caption = Label1.Caption & "5"End SubPrivate Sub Command6_Click()Label1.Caption = Label1.Caption & "6"End SubPrivate Sub Command7_Click()Label1.Caption = Label1.Caption & "7"End SubPrivate Sub Command8_Click()Label1.Caption = Label1.Caption & "8"End SubPrivate Sub Command9_Click()Label1.Caption = Label1.Caption & "9"End Sub 展开
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励30(财富值+成长值)
2个回答
展开全部
给你做一个,自己看。
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
实际上就是把加减乘除的状态要记清楚,然后再对应的变量累积上去!很简单的软件,如果自己做完了,倒是收获不少。努力吧!
追问
问题是怎么在label清零之前把数字记录下来?我把label1.caption赋值给A,但是经过测试,A没有具体数字,连零都不是。我刚学这东西没几天,麻烦讲解一下
追答
定义一个全局变量,每次要操作后把值信息都存储到这个全局变量中,LABEL1中的值就取这个全局变量里的值就可以了。。。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询