WD: Sample Function to Determine If Value Is Odd/Even (86765)



The information in this article applies to:

  • Microsoft Word for Windows 1.0
  • Microsoft Word for Windows 1.1
  • Microsoft Word for Windows 1.1a
  • Microsoft Word for Windows 2.0
  • Microsoft Word for Windows 2.0a
  • Microsoft Word for Windows 2.0b
  • Microsoft Word for Windows 2.0c
  • Microsoft Word for Windows 6.0
  • Microsoft Word for Windows 6.0a
  • Microsoft Word for Windows 6.0c
  • Microsoft Word for Windows 95
  • Microsoft Word for Windows 95 7.0a
  • Microsoft Word 97 for Windows
  • Microsoft Word for the Macintosh 6.0
  • Microsoft Word for the Macintosh 6.0.1

This article was previously published under Q86765

SUMMARY

The following Microsoft Visual Basic for Applications / WordBasic macro code checks to see if the number 11 is odd or even. You can substitute another number or a numeric variable for the number 11.
    If 11 Mod 2 = 0 Then
       Print "Number is even"
   Else
       Print "Number is odd"
   End If
				
The MOD operator divides two numbers and returns only the remainder. For example, the result of the expression 19 MOD 7 is 5. The numbers can be any numeric expressions.

REFERENCES

"Using WordBasic," by WexTech Systems and Microsoft, page 227 "Word for Windows and OS/2 Technical Reference", page 191

Kbcategory: kbusage kbmacro

Modification Type:MinorLast Reviewed:8/16/2005
Keywords:KB86765