0

Thus far I have always chosen the font Courier New because all letters are the same width. Is there any way of determining how "long" a string will be when using other fonts? I would like a way of checking the string's actual length so I can format a printout properly when using fonts that have letters with varying widths.

3
Contributors
4
Replies
5
Views
12 Years
Discussion Span
Last Post by MrConfused
0

What programming language are you using?
You could use

http://us2.php.net/manual/en/function.strlen.php

And then create an if statement to use this display with this font or that display with another font based on length.

Example:

<?php
$str = 'abcdef';
echo strlen($str); 
if ($str >= 5){
?>

<font face="arial">Arial font because its greater then or equal 5</font>

<?
} else {
?>

<font face="tahoma">Tahoma font because its less then 5</font>

<?
}
?>
0

You mean this one ?

Private Sub Form_Load()
    Me.FontName = "Verdana"
    MsgBox (Me.TextWidth("Hello"))
End Sub
0

Man I am two for two today!!

HAHA Posted PHP code in VB just now.. and earlier I posted Javascript in C#

I am calling it a day some one stick a fork in me...

0

Yes, TextWidth is the one! Thanks. I should have searched VB help a bit more before posting the question. Oh well.......

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.