CodeItBetter Programming Another VB Programming Blog

How to get the Width of the String

Posted on January 5, 2009
1
2
3
4
5
6
7
8
9
10
11
12
'String Manipulation - How to get the Width of the String

'Add a Label to your form and set AutoSize propery of the Label to True and Visible propery to False

Private Function TextWidth(sTxt As String) As Integer
    Label1.Caption = sTxt
    TextWidth = Label1.Width
End Function
 
Private Sub Main()
    MsgBox ("The width of the string 'http://codeitbetter.com' is: " & TextWidth("http://codeitbetter.com"))
End Sub
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


 

No trackbacks yet.