码迷,mamicode.com
首页 > 编程语言 > 详细

VBA计算器的全部实现

时间:2019-12-07 14:13:29      阅读:163      评论:0      收藏:0      [点我收藏+]

标签:img   技术   div   src   代码   ber   https   示例   实现   

我们将加入 除零逻辑 和 对话框提示。

 

后面 就很简单了~~~

 

提供效果图跟 代码

技术图片

代码示例

Sub 矩形1_Click()
‘
‘ 矩形1_Click Macro 代码编辑

    Dim number1 As Integer
    Dim number2 As Integer
    


    number1 = Cells(5, 4)
    number2 = Cells(6, 4)
    
    Cells(7, 4) = number1 + number2


    
End Sub
Sub 矩形2_Click()
‘
‘ 矩形2_Click Macro    Dim number1 As Integer
    Dim number2 As Integer
    
    number1 = Cells(5, 4)
    number2 = Cells(6, 4)
    
    Cells(7, 4) = number1 - number2
    
End Sub
Sub 矩形4_Click()
‘
‘ 矩形4_Click Macro    Dim number1 As Integer
    Dim number2 As Integer
    
    number1 = Cells(5, 4)
    number2 = Cells(6, 4)
    
    Cells(7, 4) = number1 * number2
End Sub
Sub 矩形5_Click()
‘
‘ 矩形5_Click Macro    number1 = Cells(5, 4)
    number2 = Cells(6, 4)
    
    If number2 = 0 Then
        MsgBox ("除数不能为零~")
    Else
    
        Cells(7, 4) = number1 / number2
    End If
    
End Sub

参考文献:

https://www.yiibai.com/vba/vba_message_box.html

 

VBA计算器的全部实现

标签:img   技术   div   src   代码   ber   https   示例   实现   

原文地址:https://www.cnblogs.com/letben/p/12001456.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!