Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / August 2005

Tip: Looking for answers? Try searching our database.

How to get string Length in points?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
LenZ - 30 Aug 2005 12:53 GMT
I want to set the "columnwidth" of my multi-column "Listbox", and I know I
have to set "columnwidth" to a string like "50;60;70" in which all numbers
are in "point", But I'm wondering how to calculate the length of a string in
points? ANy reply will be greatly appreciated. Thanks.

Signature

LenZ

Access101 - 30 Aug 2005 18:40 GMT
Is this helpful:

Converts a measurement from points to inches (1 inch = 72 points). Returns
the converted measurement as a Single.

expression.PointsToInches(Points)

expression   Optional. An expression that returns an Application object.

Points   Required Single. The measurement, in points.

Example
This example converts the measurement of the top margin for the active
document to inches and displays the result in a message box.

MsgBox PointsToInches(ActiveDocument.Sections(1) _
   .PageSetup.TopMargin)
This example converts the value of the variable sngData (a measurement in
points) to centimeters, inches, lines, millimeters, or picas, depending on
the value of the variable intUnit (a value from 1 through 5 that indicates
the resulting unit of measurement).

Function ConvertPoints(ByVal intUnit As Integer, _
   sngData As Single) As Single

   Select Case intUnit
       Case 1
           ConvertPoints = PointsToCentimeters(sngData)
       Case 2
           ConvertPoints = PointsToInches(sngData)
       Case 3
           ConvertPoints = PointsToLines(sngData)
       Case 4
           ConvertPoints = PointsToMillimeters(sngData)
       Case 5
           ConvertPoints = PointsToPicas(sngData)
       Case Else
           Error 5
   End Select

End Function

> I want to set the "columnwidth" of my multi-column "Listbox", and I know I
> have to set "columnwidth" to a string like "50;60;70" in which all numbers
> are in "point", But I'm wondering how to calculate the length of a string in
> points? ANy reply will be greatly appreciated. Thanks.
LenZ - 31 Aug 2005 13:22 GMT
Well, thanks for for your reply. But it didn't help me, what I want to do is
to set the property of columewidth for a multi-column listbox, I want to
adjust the widths of each column, and this property has to be set  as a value
in Points. To be exact, I want to get the length of a string in the unit of
Point. Do you have any idea?

Signature

LenZ

> Is this helpful:
>
[quoted text clipped - 42 lines]
> > are in "point", But I'm wondering how to calculate the length of a string in
> > points? ANy reply will be greatly appreciated. Thanks.
Klaus Linke - 30 Aug 2005 21:45 GMT
Hi LenZ,

Basically, you can't. Listboxes on allmost all machines will use a
proportional font (= the width of "l" is less than that of "m").

With a non-proportional (= fixed pitch) font, 10 characters at 12 pt font
size take up one inch (= 72 pt).
For a different font size or different number of characters, you can do the
math.

That might give you some idea of how many characters will fit. With
proportional fonts, you almost always will be able to put more characters in
the same space.

To get it more precise, you could put the desired string in the desired font
and size into a document, and use Selection.Information to get the width.

Maybe there are also API calls to get the font metrics so you can add up the
widths of the characters, but that would be above my head.

Regards,
Klaus

>I want to set the "columnwidth" of my multi-column "Listbox", and I
> know I have to set "columnwidth" to a string like "50;60;70" in which
> all numbers are in "point", But I'm wondering how to calculate the
> length of a string in points? ANy reply will be greatly appreciated.
> Thanks.

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.