编写计算器的VB代码(有图)

来源:百度知道 编辑:UC知道 时间:2024/05/12 00:59:47
根据下面的图编写计算器,记得写明每个command代表什么。
符合要求的另有重谢,拜托了。

Dim min_len As Integer
txt = txtDisplay.Text
If Left$(txt, 1) = "-" Then
min_len = 2
Else
min_len = 1
End If

If Len(txt) > min_len Then
txtDisplay.Text = Left$(txt, Len(txt) - 1)
Else
txtDisplay.Text = "0"
End If
End Sub

' Clear the current entry.
Private Sub cmdClearEntry_Click()
txtDisplay.Text = ""
End Sub
' Add a decimal point to the display.
Private Sub cmdDecimal_Click()
If InStr(txtDisplay.Text, ".") Then
Beep
Else
If NewEntry Then
txtDisplay.Text = "."
NewEntry = False
Else
txtDisplay.Text = txtDisplay.Text & "."
End If
End If
End Sub

' Calculate the result of the previous operation.
Private Sub cmdEquals_Click()
Dim new_value As Double
If txt