VB制作计算器,要求有加减乘除,清除退出,要写清楚

 我来答
牛人影视
2011-11-26 · TA获得超过1395个赞
知道大有可为答主
回答量:1491
采纳率:0%
帮助的人:1608万
展开全部
粘贴到记事本,保存成 Form1.frm文件,用VB打开即可:
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 4065
ClientLeft = 60
ClientTop = 450
ClientWidth = 3885
LinkTopic = "Form1"
ScaleHeight = 4065
ScaleWidth = 3885
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command2
Caption = "/"
Height = 495
Index = 3
Left = 2820
TabIndex = 17
Top = 2940
Width = 675
End
Begin VB.CommandButton Command2
Caption = "*"
Height = 495
Index = 2
Left = 2820
TabIndex = 16
Top = 2400
Width = 675
End
Begin VB.CommandButton Command2
Caption = "-"
Height = 495
Index = 1
Left = 2820
TabIndex = 15
Top = 1860
Width = 675
End
Begin VB.CommandButton Command2
Caption = "+"
Height = 495
Index = 0
Left = 2820
TabIndex = 14
Top = 1320
Width = 675
End
Begin VB.CommandButton Command3
Caption = "OFF"
Height = 495
Index = 1
Left = 2820
TabIndex = 13
Top = 600
Width = 675
End
Begin VB.CommandButton Command3
Caption = "AC"
Height = 495
Index = 2
Left = 1860
TabIndex = 12
Top = 2940
Width = 675
End
Begin VB.CommandButton Command3
Caption = "="
Height = 495
Index = 0
Left = 1140
TabIndex = 11
Top = 2940
Width = 675
End
Begin VB.CommandButton Command1
Caption = "9"
Height = 495
Index = 9
Left = 1860
TabIndex = 10
Top = 2400
Width = 675
End
Begin VB.CommandButton Command1
Caption = "8"
Height = 495
Index = 8
Left = 1140
TabIndex = 9
Top = 2400
Width = 675
End
Begin VB.CommandButton Command1
Caption = "7"
Height = 495
Index = 7
Left = 420
TabIndex = 8
Top = 2400
Width = 675
End
Begin VB.CommandButton Command1
Caption = "6"
Height = 495
Index = 6
Left = 1860
TabIndex = 7
Top = 1860
Width = 675
End
Begin VB.CommandButton Command1
Caption = "5"
Height = 495
Index = 5
Left = 1140
TabIndex = 6
Top = 1860
Width = 675
End
Begin VB.CommandButton Command1
Caption = "4"
Height = 495
Index = 4
Left = 420
TabIndex = 5
Top = 1860
Width = 675
End
Begin VB.CommandButton Command1
Caption = "3"
Height = 495
Index = 3
Left = 1860
TabIndex = 4
Top = 1320
Width = 675
End
Begin VB.CommandButton Command1
Caption = "2"
Height = 495
Index = 2
Left = 1140
TabIndex = 3
Top = 1320
Width = 675
End
Begin VB.CommandButton Command1
Caption = "1"
Height = 495
Index = 1
Left = 420
TabIndex = 2
Top = 1320
Width = 675
End
Begin VB.CommandButton Command1
Caption = "0"
Height = 495
Index = 0
Left = 420
TabIndex = 1
Top = 2940
Width = 675
End
Begin VB.TextBox Text1
Alignment = 1 'Right Justify
Height = 435
Left = 420
TabIndex = 0
Text = "Text1"
Top = 600
Width = 2115
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim X As Single, X1 As Single, X2 As Single
Dim FH As Integer

Private Sub Command1_Click(Index As Integer)
If FH > 0 Then
X2 = Index
Select Case FH
Case 1
X = X1 + X2
Case 2
X = X1 - X2
Case 3
X = X1 * X2
Case 4
X = X1 / X2
End Select
Else
X1 = Index
X = X1
End If
Text1 = Index
End Sub

Private Sub Command2_Click(Index As Integer)
X1 = X
FH = Index + 1
Text1 = ""
Text1.SetFocus
End Sub

Private Sub Command3_Click(Index As Integer)
Select Case Index
Case 0
Text1 = X
X1 = X
FH = 0
Case 1
Unload Me
Case 2
X1 = 0
X2 = 0
X = 0
Text1 = ""
End Select
End Sub
zx001z7d53
2011-11-26 · TA获得超过2万个赞
知道大有可为答主
回答量:2.4万
采纳率:52%
帮助的人:5615万
展开全部
715863053有现成的
本回答被网友采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
博士生小潘
2011-11-27
知道答主
回答量:46
采纳率:0%
帮助的人:23.2万
展开全部
你自己看书吧
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(1)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式