求标准型计算器VB代码,要用刚学VB的代码做

来源:百度知道 编辑:UC知道 时间:2024/06/08 21:45:39
我是刚学VB的,老师要叫我们做一个计算器出来,刚学VB不会做标准型计算器。简单的就会……
最好简单给我说明。
星期3就要叫VB了,时间紧,拜托,谢谢。

在form1中
Option Explicit
Dim cal As Boolean
Private n(100) As Double
Private c(100) As Byte, m As Byte

Private Sub cmdce_Click()
value.Caption = "0"
cal = True
End Sub

Private Sub calu_Click(Index As Integer)
On Error GoTo err
Dim i As Byte
Dim res As Double
i = Len(value.Caption)
If InStr(value.Caption, ".") Then
Do While Mid(value.Caption, i, 1) = "0"
i = i - 1
Loop
If Mid(value.Caption, i, 1) = "." Then i = i - 1
value.Caption = Left(value.Caption, i)
End If
res = Val(value.Caption)
If m = 1 Then
n(1) = res
c(1) = Index
m = 2
ElseIf Index < 2 Or (c(m - 1) > 1 And Index > 1) Then
Call total(n(m - 1), res, c(m - 1))
c(m - 1) = Index
value.Caption = CStr(n(m - 1))
Else
n(m) = Val(value.Caption): c(m) = Index: m =