How to Use TXTWIDTH() Function in FoxPro for Windows

Last reviewed: June 27, 1995
Article ID: Q94812
The information in this article applies to:
  • Microsoft FoxPro for Windows, versions 2.5 and 2.5a

SUMMARY

The TXTWIDTH() function determines the width of a character expression in the font selected for the active output window. The calculation returns the width in pixels.

MORE INFORMATION

The syntax of the TXTWIDTH() function is as follows

   TXTWIDTH(<expC1>[,<expC2>,<expN1>[,<expC3>]])

where:
  • <expC1> specifies the string to use in the calculation.
  • <expC2> specifies the font to use in the calculation.
  • <expN1> specifies the font size to use in the calculation.
  • <expC3> specifies the font style to use in the calculation.

The following examples demonstrate the usage of the TXTWIDTH() function.

This example directs output to the main FoxPro window and determines the width of the string "HELLO" in the current output font:

   ACTIVATE SCREEN
   ? TXTWIDTH("HELLO")

This example directs output to the main FoxPro window and determines the width of the string "HELLO" in 14-point Roman font:

   ACTIVATE SCREEN
   ? TXTWIDTH("HELLO","Roman",14)

This example directs output to the main FoxPro window and determines the width of the string "HELLO" in 14-point bold italic Roman font:

   ACTIVATE SCREEN
   ? TXTWIDTH("HELLO","Roman",14,"BI")


Additional reference words: FoxWin 2.50 2.50a
KBCategory: kbprg
KBSubcategory: FxprgGeneral


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: June 27, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.