用vb语言编写一个简易计算器

要求1.能够完成浮点数的加,减,乘,除;2.能够实现退格和清除功能;3.应用控件数组实现。它包含三个控件数组,分别在设计时建立:默认控件名设置控件名下标范围(index)... 要求
1.能够完成浮点数的加,减,乘,除;
2.能够实现退格和清除功能;
3.应用控件数组实现。

它包含三个控件数组,分别在设计时建立:
默认控件名 设置控件名 下标范围(index) Caption
运算符: Commond1 Operator 0-4 +-*/=
数字按钮: Commond2 Number 0-9 0123456789
数制转换按钮:Commond3 Tran 0-1 O H
展开
 我来答
匿名用户
2013-12-05
展开全部
Dim N1 As Single
Dim ysf As String
Dim qing As Boolean
Dim M As Single
Private Sub C_Click(Index As Integer)
If qing = True Then
L.Caption = ""
qing = False
End If
L.Caption = L.Caption & C(Index).Caption
End Sub

Private Sub Command1_Click()
qing = True
Dim N2 As Single
Dim T As Single
N2 = Val(L.Caption)
Select Case ysf
Case "+"
T = N1 + N2
Case "-"
T = N1 - N2
Case "*"
T = N1 * N2
Case "/"
T = N1 / N2
End Select
L.Caption = T

End Sub

Private Sub Command10_Click()
M = Val(L.Caption)
L1.Caption = "M"
End Sub

Private Sub Command11_Click()
M = M + Val(L.Caption)
End Sub

Private Sub Command2_Click()
L.Caption = -Val(L.Caption)
End Sub

Private Sub Command3_Click()
If L.Caption <> "" Then
L.Caption = Left(L.Caption, Len(L.Caption) - 1)
End If
End Sub

Private Sub Command4_Click()
N1 = 0
L.Caption = ""
ysf = "+"
End Sub

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

Private Sub Command6_Click()
L.Caption = Sqr(Val(L.Caption))
qing = True
End Sub

Private Sub Command7_Click()
L.Caption = 1 / (Val(L.Caption))
End Sub

Private Sub Command8_Click()
M = 0
L1.Caption = ""
End Sub

Private Sub Command9_Click()
L.Caption = M
End Sub

Private Sub Form_Load()
ysf = "+"
End Sub

Private Sub s_Click(Index As Integer)
N1 = L.Caption
ysf = s(Index).Caption
qing = True
End Sub

Private Sub xsd_Click()
If qing = True Then
L.Caption = ""
qing = False
End If
If InStr(1, L.Caption, ".") = 0 Then
L.Caption = L.Caption & "."
End If
End Sub
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
匿名用户
2013-12-05
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

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

类别

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

说明

0/200

提交
取消

辅 助

模 式