Mod Operator - Microsoft Visual Basic Constants Documentation

Mod Operator

Microsoft Visual Basic Constants

previous page next page Mod Operator

       

Used to divide two numbers and return only the remainder.

Syntax

result = number1 Mod number2

The Mod operator syntax has these parts:

Part Description
result Required; any numeric variable.
number1 Required; any numeric expression.
number2 Required; any numeric expression.

Remarks

The modulus, or remainder, operator divides number1 by number2 (rounding floating-point numbers to integers) and returns only the remainder as result. For example, in the following expression, A (result) equals 5.

A = 19 Mod 6.7

Usually, the data type of result is a Byte, Byte variant, Integer, Integer variant, Long, or Variant containing a Long, regardless of whether or not result is a whole number. Any fractional portion is truncated. However, if any expression is Null, result is Null. Any expression that is Empty is treated as 0.

previous page start next page
  • Homepage

Table of contents

  • Constants
    • Calendar Constants
    • CallType Constants
    • Color Constants
    • Comparison Constants
    • Compiler Constants
    • Date Constants
    • Date Format Constants
    • Dir Constants
    • DriveType Constants
    • File Attribute Constants
    • File Input/Output Constants
    • Form Constants
    • GetAttr Constants
    • IMEStatus Constants
    • Keycode Constants
    • Miscellaneous Constants
    • MsgBox Constants
    • QueryClose Constants
    • SetAttr Constants
    • Shell Constants
    • SpecialFolder Constants
    • StrConv Constants
    • System Color Constants
    • Tristate Constants
    • VarType Constants
    • Visual Basic Constants
  • Data Types
    • Boolean Data Type
    • Byte Data Type
    • Currency Data Type
    • Date Data Type
    • Decimal Data Type
    • Double Data Type
    • Integer Data Type
    • Long Data Type
    • Object Data Type
    • Single Data Type
    • String Data Type
    • User-Defined Data Type
    • Variant Data Type
  • Directives
    • #Const Directive
    • #If...Then...#Else Directive
  • Events
    • Activate Event
    • Deactivate Event
    • Initialize Event
    • QueryClose Event
    • Resize Event
    • Terminate Event
  • Functions
    • A-C
      • Abs Function
      • Array Function
      • Asc Function
      • AscB Function
      • AscW Function
      • Atn Function
      • CallByName Function
      • CBool Function
      • CByte Function
      • CCur Function
      • CDate Function
      • CDbl Function
      • CDec Function
      • Choose Function
      • Chr Function
      • Chr$ Function
      • ChrB Function
      • ChrB$ Function
      • ChrW Function
      • CInt Function
      • CLng Function
      • Command Function
      • Command$ Function
      • Cos Function
      • CreateObject Function
      • CSng Function
      • CStr Function
      • CurDir Function
      • CurDir$ Function
      • CVar Function
      • CVDate Function
      • CVErr Function
    • D-G
      • Date Function
      • Date$ Function
      • DateAdd Function
      • DateDiff Function
      • DatePart Function
      • DateSerial Function
      • DateValue Function
      • Day Function
      • DDB Function
      • Dir Function
      • Dir$ Function
      • DoEvents Function
      • Environ Function
      • Environ$ Function
      • EOF Function
      • Error Function
      • Error$ Function
      • Exp Function
      • FileAttr Function
      • FileDateTime Function
      • FileLen Function
      • Filter Function
      • Fix Function
      • Format Function
      • Format$ Function
      • FormatCurrency Function
      • FormatDateTime Function
      • FormatNumber Function
      • FormatPercent Function
      • FreeFile Function
      • FV Function
      • GetAllSettings Function
      • GetAttr Function
      • GetObject Function
      • GetSetting Function
    • H-L
      • Hex Function
      • Hex$ Function
      • Hour Function
      • IIf Function
      • IMEStatus Function
      • Input Function
      • Input$ Function
      • InputB Function
      • InputB$ Function
      • InputBox Function
      • InStr Function
      • InStrB Function
      • InStrRev Function
      • Int Function
      • IPmt Function
      • IRR Function
      • IsArray Function
      • IsDate Function
      • IsEmpty Function
      • IsError Function
      • IsMissing Function
      • IsNull Function
      • IsNumeric Function
      • IsObject Function
      • Join Function
      • LBound Function
      • LCase Function
      • LCase$ Function
      • Left Function
      • Left$ Function
      • LeftB Function
      • LeftB$ Function
      • Len Function
      • LenB Function
      • Loc Function
      • LOF Function
      • Log Function
      • LTrim Function
      • LTrim$ Function
    • M-P
      • MacID Function
      • MacScript Function
      • Mid Function
      • Mid$ Function
      • MidB Function
      • MidB$ Function
      • Minute Function
      • MIRR Function
      • Month Function
      • MonthName Function
      • MsgBox Function
      • Now Function
      • NPer Function
      • NPV Function
      • Oct Function
      • Oct$ Function
      • Partition Function
      • Pmt Function
      • PPmt Function
      • PV Function
    • Q-Z
      • QBColor Function
      • Rate Function
      • Replace Function
      • RGB Function
      • Right Function
      • Right$ Function
      • RightB Function
      • RightB$ Function
      • Rnd Function
      • Round Function
      • RTrim Function
      • RTrim$ Function
      • Second Function
      • Seek Function
      • Sgn Function
      • Shell Function
      • Sin Function
      • SLN Function
      • Space Function
      • Space$ Function
      • Spc Function
      • Split Function
      • Sqr Function
      • Str Function
      • Str$ Function
      • StrComp Function
      • StrConv Function
      • StrReverse Function
      • String Function
      • String$ Function
      • Switch Function
      • SYD Function
      • Tab Function
      • Tan Function
      • Time Function
      • Time$ Function
      • Timer Function
      • TimeSerial Function
      • TimeValue Function
      • Type Conversion Functions
      • Trim Function
      • Trim$ Function
      • TypeName Function
      • UBound Function
      • UCase Function
      • UCase$ Function
      • Val Function
      • VarType Function
      • Weekday Function
      • WeekdayName Function
      • Year Function
  • Groups
    • Arithmetic Operators
    • Concatenation Operators
    • Conversion Functions
    • Data Type Summary
    • Derived Math Functions
    • Logical Operators
    • Math Functions
    • Operator Precedence
    • Operator Summary
  • Indexes/Lists
    • Arrays Keyword Summary
    • Collection Object Keyword Summary
    • Compiler Directive Keyword Summary
    • Control Flow Keyword Summary
    • Conversion Keyword Summary
    • Data Types Keyword Summary
    • Dates and Times Keyword Summary
    • Directories and Files Keyword Summary
    • Errors Keyword Summary
    • Financial Keyword Summary
    • Input and Output Keyword Summary
    • Keywords by Task
    • Math Keyword Summary
    • Miscellaneous Keyword Summary
    • Operators Keyword Summary
    • Registry Keyword Summary
    • String Manipulation Keyword Summary
    • Variables and Constants Keyword Summary
  • Keywords
    • As
    • Binary
    • ByRef
    • ByVal
    • Date
    • Else
    • Empty
    • Error
    • False
    • For
    • Friend
    • Get
    • Input
    • Is
    • Len
    • Let
    • Lock
    • Me
    • Mid
    • New
    • Next
    • Nothing
    • Null
    • On
    • Option
    • Optional
    • ParamArray
    • Print
    • Private
    • Property
    • Public
    • Resume
    • Seek
    • Set
    • Static
    • Step
    • String
    • Then
    • Time
    • To
    • True
    • WithEvents
  • Methods
    • Add Method
    • Add Method (Dictionary)
    • Add Method (Folders)
    • Assert Method
    • BuildPath Method
    • Clear Method
    • Close Method
    • Copy Method
    • CopyFile Method
    • CopyFolder Method
    • CreateFolder Method
    • CreateTextFile Method
    • Delete Method
    • DeleteFile Method
    • DeleteFolder Method
    • DriveExists Method
    • Exists Method
    • FileExists Method
    • FolderExists Method
    • GetAbsolutePathName Method
    • GetBaseName Method
    • GetDrive Method
    • GetDriveName Method
    • GetExtensionName Method
    • GetFile Method
    • GetFileName Method
    • GetFolder Method
    • GetParentFolderName Method
    • GetSpecialFolder Method
    • GetTempName Method
    • Hide Method
    • Item Method
    • Items Method
    • Keys Method
    • Move Method (UserForm)
    • Move Method (FileSystemObject Object)
    • MoveFile Method
    • MoveFolder Method
    • OpenAsTextStream Method
    • OpenTextFile Method
    • Print Method
    • PrintForm Method
    • Raise Method
    • Read Method
    • ReadAll Method
    • ReadLine Method
    • Remove Method
    • Remove Method (FileSystemObject Object)
    • RemoveAll Method
    • Show Method
    • Skip Method
    • SkipLine Method
    • WhatsThisMode Method
    • Write Method
    • WriteBlankLines Method
    • WriteLine Method
  • Miscellaneous
    • Character Set (0-127)
    • Character Set (128-255)
    • Document Conventions
  • Objects
    • Collection Object
    • Debug Object
    • Dictionary Object
    • Drive Object
    • Drives Collection
    • Err Object
    • File Object
    • Files Collection
    • FileSystemObject Object
    • Folder Object
    • Folders Collection
    • TextStreamObject
    • UserForm Object
    • UserForms Collection
  • Operators
    • & Operator
    • * Operator
    • + Operator
    • - Operator
    • / Operator
    • \ Operator
    • ^ Operator
    • = Operator
    • AddressOf Operator
    • And Operator
    • Comparison Operators
    • Eqv Operator
    • Imp Operator
    • Is Operator
    • Like Operator
    • Mod Operator
    • Not Operator
    • Or Operator
    • Xor Operator
  • Properties
    • AtEndOfLine Property
    • AtEndOfStream Property
    • Attributes Property
    • AvailableSpace Property
    • Caption Property (UserForm)
    • Calendar Property
    • Column Property
    • CompareMode Property
    • Count Property
    • Count Property (FileSystemObject Object)
    • DateCreated Property
    • DateLastAccessed Property
    • DateLastModified Property
    • Description Property
    • Drive Property
    • DriveLetter Property
    • Drives Property
    • DriveType Property
    • Enabled Property (UserForm)
    • Files Property
    • FileSystem Property
    • FreeSpace Property
    • Height Property (UserForm)
    • HelpContext Property
    • HelpContextID Property (UserForm)
    • HelpFile Property
    • IsReady Property
    • IsRootFolder Property
    • Item Property
    • Key Property
    • LastDLLError Property
    • Left Property (UserForm)
    • Line Property
    • Name Property (FileSystemObject Object)
    • Name Property (UserForm)
    • Number Property
    • ParentFolder Property
    • Path Property (FileSystemObject Object)
    • RightToLeft Property
    • RootFolder Property
    • SerialNumber Property
    • ShareName Property
    • ShortName Property
    • ShortPath Property
    • ShowModal Propety
    • Size Property (FileSystemObject Object)
    • Source Property
    • StartUpPosition Property
    • SubFolders Property
    • Tag Property (UserForm)
    • TotalSize Property
    • Top Property (UserForm)
    • Type Property
    • Visible Property (UserForm)
    • VolumeName Property
    • WhatsThisButton Property
    • WhatsThisHelp Property
    • Width Property (UserForm)
  • Statements
    • A-L
      • AppActivate Statement
      • Beep Statement
      • Call Statement
      • ChDir Statement
      • ChDrive Statement
      • Close Statement
      • Const Statement
      • Date Statement
      • Declare Statement
      • Deftype Statements
      • DeleteSetting Statement
      • Dim Statement
      • Do...Loop Statement
      • End Statement
      • Enum Statement
      • Erase Statement
      • Error Statement
      • Event Statement
      • Exit Statement
      • FileCopy Statement
      • For Each...Next Statement
      • For...Next Statement
      • Function Statement
      • Get Statement
      • GoSub...Return Statement
      • GoTo Statement
      • If...Then...Else Statement
      • Implements Statement
      • Input # Statement
      • Kill Statement
      • Let Statement
      • Line Input # Statement
      • Load Statement
      • Lock Statement
      • LSet Statement
    • M-Z
      • Mid Statement
      • MidB Statement
      • MkDir Statement
      • Name Statement
      • On Error Statement
      • On...GoSub Statement
      • On...GoTo Statement
      • Open Statement
      • Option Base Statement
      • Option Compare Statement
      • Option Explicit Statement
      • Option Private Statement
      • Print # Statement
      • Private Statement
      • Property Get Statement
      • Property Let Statement
      • Property Set Statement
      • Public Statement
      • Put Statement
      • RaiseEvent Statement
      • Randomize Statement
      • ReDim Statement
      • Rem Statement
      • Reset Statement
      • Resume Statement
      • RmDir Statement
      • RSet Statement
      • SaveSetting Statement
      • Seek Statement
      • Select Case Statement
      • SendKeys Statement
      • Set Statement
      • SetAttr Statement
      • Static Statement
      • Stop Statement
      • Sub Statement
      • Time Statement
      • Type Statement
      • Unload Statement
      • While...Wend Statement
      • Width # Statement
      • With Statement
      • Write # Statement

Submit feedback about this site to:

  • [email protected]

Từ khóa » Visual Basic Mod Operator