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.