不过我觉得我的方法可能笨了。
Private Sub Operator_Click(Index As Integer)
If C.OperateState = 函数 Then
Exit Sub
End If
' If C.OperateState = 计算 And Check3.Value = 0 Then
' Text1(0) = ""
' C.OperateState = 无
If Index <= 9 Then
If (C.OperateState = 计算 Or C.OperateState = 无) And JG <> "" And Check3.Value = 1 Then
Text1(0) = JG
C.OperateState = 数字
Else
C.OperateState = C.GetOperationState(Text1(0))
End If
If Index = 2 Then '''如果为“-”号
If C.OperateState = 无 Then
Text1(0) = Operator(Index).Caption
C.OperateState = 正负号
IsExistDot = False
ElseIf C.OperateState >= 20 And C.OperateState <= 29 Then '''双目可加
Text1(0) = Text1(0) & Operator(Index).Caption
C.OperateState = 正负号
IsExistDot = False
ElseIf C.OperateState >= 30 And C.OperateState <= 41 Then '''单目可加
Text1(0) = Text1(0) & " " & Operator(Index).Caption & " "
C.OperateState = 减法运算
IsExistDot = False
ElseIf C.OperateState <= 11 And C.OperateState <> 正负号 Then
If C.OperateState = 3 Then
Text1(0) = Text1(0) & Operator(Index).Caption
C.OperateState = 正负号
Else
Text1(0) = Text1(0) & " " & Operator(Index).Caption & " "
C.OperateState = 减法运算
End If
IsExistDot = False
Else
End If
Else '''如果前面为无、数字、小数点、阶乘
If Index = 8 Then
If C.OperateState = 无 Then
Text1(0) = Operator(Index).Caption & " "
C.OperateState = 非运算
IsExistDot = False
ElseIf C.OperateState >= 20 And C.OperateState <= 42 And C.OperateState <> 阶乘运算 Then
Text1(0) = Text1(0) & Operator(Index).Caption & " "
C.OperateState = 非运算
IsExistDot = False
Else
End If
Else
If C.OperateState = 阶乘运算 Or C.OperateState > 无 And C.OperateState <= 10 And C.OperateState <> 正负号 Or C.OperateState = 后括号 Then
Text1(0) = Text1(0) & " " & Operator(Index).Caption & " "
C.OperateState = C.GetOperationState(Operator(Index).Caption)
IsExistDot = False
ElseIf C.OperateState = 无 And (JG <> "" Or JG <> "0.") And Check3.Value = 1 Then
Text1(0) = Val(JG) & " " & Operator(Index).Caption & " "
C.OperateState = C.GetOperationState(Operator(Index).Caption)
IsExistDot = False
Else
End If
End If
End If
Else ''''单目运算符
If Index = 21 Then
C.OperateState = C.GetOperationState(Text1(0))
If C.OperateState = 数字 And C.IsExistDot = False Then
Text1(0) = Text1(0) & Operator(Index).Caption
C.OperateState = 阶乘运算
IsExistDot = False
End If
ElseIf (C.OperateState = 计算 Or C.OperateState = 无) And JG <> "" And Check3.Value = 1 Then
Text1(0) = Operator(Index).Caption & " " & Val(JG) & " "
Text1(1) = "0."
C.OperateState = C.GetOperationState(Operator(Index).Caption)
IsExistDot = False
ElseIf (C.OperateState <> 后括号 And C.OperateState <> 数字 And C.OperateState <> 小数点 And C.OperateState <> 单目运算 Or C.OperateState = 无 And JG = "") And C.OperateState <> 计算 Then
If C.OperateState = 无 Then
Text1(0) = Operator(Index).Caption & " "
Text1(1) = "0."
Else
Text1(0) = Text1(0) & " " & Operator(Index).Caption & " "
End If
C.OperateState = C.GetOperationState(Operator(Index).Caption)
IsExistDot = False
End If
End If
If (C.OperateState >= 20 And C.OperateState <= 42) And C.ErrorString <> "" Then
Text1(1) = "0."
End If
End Sub