要我要求用VB编个计算器,分数可追加

来源:百度知道 编辑:UC知道 时间:2024/06/01 13:49:52
一、1个text
二、11个数字键(0-9 还有个小数点) 作为一个控件数组
三、+-*/ 四个符号键 作为一个控件数组
四、=
五、OFF

合我心意的话我追加分
帮我改下吧
Dim a As Single '第一个数
Dim b As Single '第二个数
Dim c As Integer '符号
Private Sub Command1_Click(Index As Integer)
Text1.Text = Text1.Text & Command1(Index).Caption
End Sub
Private Sub Command2_Click(Index As Integer)
Text1.Text = ""
Select Case Command2(Index)
Case 0
Text1.Text = a + b
Case 1
Text1.Text = a - b
Case 2
Text1.Text = a * b
Case 3
Text1.Text = a / b
End Select
End Sub
Private Sub Command3_Click()
End
End Sub

你是要什么版本的。VB6?VB.NET?

好的,那写好了怎么给你。

我觉得最简单的就是使用ScriptControl,好好利用软件行业的可重用思想:)
引用->Microsoft Script Control 1.0,代码如下:
Dim s As New ScriptControl
Private Sub Form_Load()
s.Language = "VbScript"
MsgBox s.Eval("sin(1)+1")
Set s = Nothing
End Sub

我有,已做好的,带文档的.QQ41977254,还有复杂计算器

Option Explicit

Dim Number1 As Double, Number2 As Double, Operator As String

Dim OP As Boolean, fmt As String

Private Sub cmbAC_Click()

  Number1 = 0: Number2 = 0: Text1.Text = "0": Label1.Caption = "" '×ÜÇå³ý

End Sub

Private Sub cmbEqual_Click()

  If Label1.Caption <> "" Then '&Egrav