Dim fontToMeasure As New Font("Microsoft Sans Serif", 14, FontStyle.Bold) Dim sizeOfString As New SizeF Dim g As Graphics = Me.CreateGraphics sizeOfString = g.MeasureString("This is line 1" & vbcrlf & "This is line 2", fontToMeasure) Debug.WriteLine("String Height: " & sizeOfString.Height) Debug.WriteLine("String Width: " & sizeOfString.Width)
If you want to limit the width (so it wraps), use below (300 was my width to set as max):
Dim fontToMeasure As New Font("Microsoft Sans Serif", 14, FontStyle.Bold) Dim sizeOfString As New SizeF Dim g As Graphics = Me.CreateGraphics sizeOfString = g.MeasureString("This is line 1" & vbcrlf & "This is line 2", fontToMeasure, 300) Debug.WriteLine("String Height: " & sizeOfString.Height) Debug.WriteLine("String Width: " & sizeOfString.Width)