Mod 运算符 | 您所在的位置:网站首页 › 余数函数 › Mod 运算符 |
Mod 运算符
项目
04/07/2023
Used to divide two numbers and return only the remainder. 语法结果 = number1Modnumber2 “Mod”运算符语法包含以下部分: Part 说明 result 必需,任何数值变量。 number1 必需,任何数值表达式。 number2 必需,任何数值表达式。 备注取模或余数运算符用 number1 除以 number2(将浮点数舍入为整数 )并仅返回余数作为结果。 例如,在下面的表达式中,(结果)等于 5。 A = 19 Mod 6.7通常,结果 的数据类型 为字节、“字节”变量、整数、“整数”变量、Long 或包含“Long”的变量,而无论结果 是否是整数。 截断了任何小数部分。 但是,如有任何表达式为 Null,则结果 为 Null。 任何为空的表达式均将被视为 0。 示例This example uses the Mod operator to divide two numbers and return only the remainder. If either number is a floating-point number, it is first rounded to an integer. Dim MyResult MyResult = 10 Mod 5 ' Returns 0. MyResult = 10 Mod 3 ' Returns 1. MyResult = 12 Mod 4.3 ' Returns 0. MyResult = 12.6 Mod 5 ' Returns 3. 另请参阅 (早期版本) 的 Mod 运算符示例 Data types 运算符摘要 支持和反馈有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。 |
CopyRight 2018-2019 实验室设备网 版权所有 |