VBA Excel口算题

口算题函数

利用随机数写个20以内加减法口算题函数

vbscript 复制代码
Function Kousuan()
    Dim intOne As Integer
    Dim intTwo As Integer
    Dim strFlg As String
    Dim intFlg As Integer
    Dim strRtn As String
    
    intFlg = Application.WorksheetFunction.RandBetween(0, 1)
    strFlg = "-"
    If intFlg = 0 Then strFlg = "+"
    
    intOne = Application.WorksheetFunction.RandBetween(10, 20)
    intTwo = Application.WorksheetFunction.RandBetween(1, 20)
    
    If strFlg = "-" Then
        If intOne > intTwo Then
            strRtn = intOne & strFlg & intTwo & "="
        Else
            strRtn = intTwo & strFlg & intOne & "="
        End If
    Else
        strRtn = intOne & strFlg & intTwo & "="
    End If
    
    shuxue = strRtn
End Function
相关推荐
SunnyDays10118 天前
如何使用 Python 添加和编辑 Excel VBA 宏(无需安装 Excel)
开发语言·python·excel·vba
taller_200013 天前
【005】PiE 与传统 VBA 的核心区别
python·vba·pie·py
VBA63371 个月前
VBA密匙暗码加密技术
vba
VBA63371 个月前
VBA代码加密解决方案目录及说明
vba
VBA63372 个月前
如何学习VBA之2.1.3 VBA的错误处理
vba
VBA63372 个月前
VBA高级应用30例 应用6 第5部分:5 利用VBA从XML文件中导出数值数据
vba
VBA63372 个月前
VBA信息获取与处理专题七第二节 网络通信过程的解读
vba
VBA63372 个月前
数组与字典解决方案第二十九讲 数组的创建方法小结及回填的注意事项
vba
小妖6663 个月前
excel 怎么在单元格内容自动加上一段文字不能用公式
excel·vba
VBA63373 个月前
VBA之Word应用第五章第五节 Range对象的属性(四)
vba