Setting and Evaluating Values for a Dialog CheckBox

Last reviewed: November 17, 1997
Article ID: Q87111
The information in this article applies to:
  • Microsoft Word for Windows, versions 6.0, 6.0a, 6.0c 2.0c, 6.0, 6.0a, 6.0c
  • Microsoft Word for Windows 95, versions 7.0, 7.0a
  • Microsoft Word for the Macintosh, versions 6.0, 6.0.1

SUMMARY

User-defined dialog boxes created in the Microsoft Word for Windows macro language, can include check boxes that are marked, unmarked, or unavailable (dimmed). To set the default value for a check box, set the CheckBox dialog argument to one of the following values:

  0   Clear the check box
  1   Place an X in the check box
 -1   Make the check box unavailable (dimmed)

These values are also returned to indicate the status of the check box. For example, if the user marks a check box, the value "1" is returned to indicate that the box was selected (marked).

To check the return value for a CheckBox statement, add a command similar to the following just below the Dialog statement:

   x = Dlg.CheckBox1

   Dlg = the dialog box array
   CheckBox1 = dialog box field name

If the "x" variable evaluates to be "1", CheckBox1 in the UserDialog was selected.

The following macro evaluates CheckBox1 in the UserDialog dialog record:

 Sub MAIN
   Begin Dialog UserDialog 320, 120
      OKButton 210, 56, 88, 22
      CancelButton 211, 83, 88, 21
      CheckBox 35, 24, 196, 17, "Check Box", .CheckBox1
   End Dialog
   Dim dlg As UserDialog
   n = Dialog(dlg)
   x = dlg.checkbox1                  'assign status of Checkbox1 to x
   If x = 1 Then MsgBox "Checkbox was checked"
 End Sub

MORE INFORMATION

In addition to evaluating check boxes, CheckBox statements can be set to default values. The following macro fills CheckBox1 with gray in the UserDialog dialog record:

 Sub MAIN
   Begin Dialog UserDialog 320, 120
      OKButton 210, 56, 88, 22
      CancelButton 211, 83, 88, 21
      CheckBox 35, 24, 196, 17, "Greyed Check Box", .CheckBox1
      CheckBox 35, 42, 111, 16, "Check Box", .CheckBox2
   End Dialog
   Dim dlg As UserDialog
   dlg.CheckBox1 = - 1                'Sets CheckBox1 to gray
   n = Dialog(dlg)
 End Sub

The default display for a CheckBox statement is clear (no check mark).

Word 6.0 for Windows

In order to actually disable an item in a dialog, use the DlgEnable statement within a dialog function. DlgEnable allows you to enable or disable the dialog box control identified by Identifier[$] while the dialog box is displayed. When a dialog box control is disabled, it is visible in the dialog box, but is dimmed and not functional.

For information about using a dialog function, see the "Creating Dynamic Dialog Boxes" topic in the Online Help file for Word 6.0 for Windows.

REFERENCES

"Using WordBasic," by WexTech Systems and Microsoft, page 162


Additional query words: word basic
Keywords : macword winword winword2 word6 word7 word95 kbmacro
Version : WINDOWS: 6.0, 6.0a, 6.0c, 7.0, 7.0a; MACINTOSH 6.0, 6.0.1
Platform : MACINTOSH WINDOWS


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: November 17, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.